Skip to main content

How does Coolhand track thinking blocks and reasoning tokens across providers?

Last updated 6 min read

Coolhand separates internal reasoning from visible outputs, storing chain-of-thought text in Thinking Response and token counts in Reasoning Tokens. Google Gemini and Anthropic Claude expose thinking text, OpenAI Chat Completions exposes only token counts, OpenAI Responses API provides reasoning summaries, and Ollama returns thinking text when requested. Reasoning tokens bill at provider output or reasoning rates.

Coolhand captures extended thinking and chain-of-thought reasoning from models that expose their internal deliberation. Because providers report reasoning differently—ranging from full scratchpad text to hidden tokens or cryptographically redacted blocks—Coolhand normalizes these structures so your logs remain consistent, parsable, and clean.

For an overview of all standard log fields, see What every field on an LLM request log means.


Separation of thinking and visible responses

When reasoning models deliberate before replying, mixing their scratchpad thoughts with the final output risks corrupting JSON schemas, tool arguments, or customer-facing chat interfaces.

Coolhand strictly separates internal reasoning from model outputs during ingestion:

  • Assistant Response: Contains only the final user-facing text or tool calls produced by the model.
  • Thinking Response: Contains the extracted thinking or reasoning content, stored as an array of text blocks.
  • Reasoning Tokens: Records the exact number of tokens consumed by the reasoning process when the provider reports this count.

This separation ensures downstream parsers receive clean outputs without manual strip-filtering.


Provider capability matrix

Providers differ in whether they return the text of the model's reasoning, only a token count, or summaries:

Provider / API Surface Thinking Response Reasoning Tokens Prerequisite Setup
Google Vertex AI / Gemini Full thought parts Yes (thoughtsTokenCount) Configure thinking_config in generation_config
OpenAI Chat Completions No (hidden by API) Yes (in completion token details) None (available on o1, o3, and reasoning models)
OpenAI Responses API Summaries (summary_text) Yes (in output token details) Pass "reasoning": {"summary": "auto"}
Anthropic Claude Content blocks (full or summarized) No (bundled into Output Tokens) Pass thinking budget parameter
Ollama Full thinking text No (not reported) Pass think: true in request options

Provider details and behaviors

Google Vertex AI and Gemini

Google exposes both the reasoning text and granular token counts for thinking-capable models (such as Gemini 2.5 Pro and Gemini 2.5 Flash).

  • How thinking appears: Responses include candidate parts flagged with "thought": true, alongside standard text parts. Usage includes thoughtsTokenCount within usageMetadata.
  • What Coolhand captures: Coolhand extracts text from parts where thought is true into Thinking Response, records thoughtsTokenCount into Reasoning Tokens, and places non-thought parts into Assistant Response.
  • Setup prerequisite: Include thinking_config with include_thoughts: true and a thinking_budget in your request's generation_config.
  • Streaming: Supported for both streaming (streamGenerateContent) and non-streaming calls.
{
  "candidates": [{
    "content": {
      "role": "model",
      "parts": [
        { "thought": true, "text": "Analyzing user constraints..." },
        { "text": "Here is the recommended solution." }
      ]
    }
  }],
  "usageMetadata": {
    "promptTokenCount": 12,
    "candidatesTokenCount": 18,
    "thoughtsTokenCount": 85
  }
}

Anthropic Claude

Extended thinking is available on models such as Claude 3.7 Sonnet and Claude 4 series.

  • How thinking appears: Responses return content blocks with "type": "thinking".
  • What Coolhand captures: Coolhand extracts the "thinking" text string from thinking blocks into Thinking Response. Visible text blocks ("type": "text") populate Assistant Response.
  • Token counts: Anthropic does not break out reasoning tokens into a separate field. All tokens generated during thinking are rolled into usage.output_tokens. Consequently, Reasoning Tokens is blank on Anthropic logs, and the billable output token count already accounts for the full thinking process.
  • Full vs. summarized thinking: Claude 3.7 Sonnet returns full thinking text. Claude 4 and newer models return summarized thinking blocks while billing for full internal thinking tokens.
  • Setup prerequisite: Pass the thinking parameter with a token budget (e.g. {"thinking": {"type": "enabled", "budget_tokens": 2048}}) and an adequate max_tokens limit. Standard requests without this parameter do not output thinking blocks.

Redacted thinking blocks

Occasionally, Anthropic's internal safety classifiers flag Claude's thinking process. When this occurs, Anthropic returns an encrypted content block:

{
  "type": "redacted_thinking",
  "data": "gAAAAABencrypted..."
}

When Coolhand encounters these blocks:

  1. It records [redacted thinking] as a placeholder in Thinking Response.
  2. The placeholder indicates safety systems flagged the reasoning chain; the payload cannot be decrypted outside Anthropic.
  3. This redaction does not degrade the final response quality, and the model still uses the encrypted context when continuing multi-turn conversations.

OpenAI

OpenAI behaves differently depending on whether you use the Chat Completions API or the Responses API.

Chat Completions API (/v1/chat/completions)

For reasoning models (such as o1, o3, and o4-mini):

  • Reasoning text: OpenAI deliberately conceals chain-of-thought text. Thinking Response remains blank.
  • Reasoning tokens: OpenAI exposes reasoning token counts inside usage.completion_tokens_details. Coolhand records this integer directly in Reasoning Tokens.
{
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 1240,
    "completion_tokens_details": {
      "reasoning_tokens": 1024
    }
  }
}

Responses API (/v1/responses)

OpenAI's Responses API allows models to return reasoning summaries:

  • What Coolhand captures: Text from summary_text entries within reasoning output items is extracted into Thinking Response.
  • Token counts: Extracted from usage.output_tokens_details.reasoning_tokens into Reasoning Tokens.
  • Setup prerequisite: You must explicitly request summaries by passing "reasoning": {"summary": "auto"} in your payload.

Ollama

Self-hosted reasoning models running in Ollama (such as DeepSeek R1, QwQ, or Qwen3) expose reasoning in dedicated fields.

  • How thinking appears: Ollama outputs thinking text in message.thinking (Chat API) or thinking (Generate API).
  • What Coolhand captures: The thinking text is stored in Thinking Response.
  • Reasoning tokens: Ollama does not report dedicated reasoning token counts; Reasoning Tokens is blank.
  • Setup prerequisite: Pass think: true in your Ollama request payload or options to ensure thinking text is generated and returned.

Billing and cost accounting

Reasoning tokens contribute directly to your model inference costs:

  1. Explicit reasoning rates: When a model defines a distinct reasoning token price, Coolhand applies that rate to Reasoning Tokens. If no separate reasoning rate exists, reasoning tokens are billed at the model's standard output token rate.
  2. Anthropic billing: Because Anthropic bundles thinking tokens directly into Output Tokens, your cost calculation automatically reflects thinking output at the model's standard output price without requiring a separate Reasoning Tokens tally.
  3. Long-context tier interactions: If your request uses a model with tiered pricing thresholds (e.g. Gemini 2.5 Pro or Claude long-context tiers), large input prompts can trigger higher rates across the entire request, including output and reasoning tokens.

To monitor provider billing status and alerts across your workspaces, review How do provider credential and billing alerts work?.

Related articles