Sub topic 8
Seeing the reasoning: summaries and thinking blocks
Reasoning models think before they answer, but the API does not always show you that thinking. This chapter covers what each major API returns, how to request it, and what you can and cannot do with it.
It assumes you have read the earlier chapters on reasoning tokens and output limits. You should also be comfortable reading Python that calls an LLM API and walks over a response object.
Why the reasoning is not simply returned
Reasoning tokens are generated, counted and billed, as the chapter on reasoning tokens explained. Whether you get to read them is a separate decision made by the provider. Two patterns are common:
- Summaries. A second step condenses the raw reasoning into a shorter text. You receive the summary, not the original tokens.
- Thinking blocks. The response contains typed content blocks, one for thinking and one for the final text. The thinking block may hold the full reasoning or a summary, depending on the model.
Neither pattern changes what you pay for. You are billed for the full reasoning that the model produced, not for the length of the visible summary. A response with a three-line summary can still use thousands of reasoning tokens.
Reading reasoning summaries with the OpenAI Responses API
With OpenAI reasoning models, you ask for a summary through the summary field of the reasoning parameter. Accepted values are "auto", "concise" and "detailed". Which values a model supports varies, and some organizations must complete identity verification before summaries are returned. If you request a summary and get none, check those two things first.
The response's output is a list of items. A reasoning item has type == "reasoning" and a summary list of text parts. The answer is in an item with type == "message".
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="o4-mini",
reasoning={"effort": "medium", "summary": "auto"},
input="A train leaves at 14:10 and arrives at 17:45. How long is the trip?",
)
for item in response.output:
if item.type == "reasoning":
if not item.summary:
print("[summary] (none returned)")
for part in item.summary:
print("[summary]", part.text)
elif item.type == "message":
for part in item.content:
if part.type == "output_text":
print("[answer]", part.text)
usage = response.usage
print("reasoning tokens:", usage.output_tokens_details.reasoning_tokens)
print("total output tokens:", usage.output_tokens)An empty summary list is normal. With "auto", the model may skip the summary when the problem was easy, so write code that accepts the empty case.
The summary describes the reasoning at a high level. It is not a transcript, so you should not expect to find every intermediate calculation in it.
Reading thinking blocks with the Anthropic Messages API
With extended thinking enabled, Anthropic returns a list of content blocks. A block's type tells you what it holds. Three types matter here:
| Block type | Contents | Notes |
|---|---|---|
| `thinking` | The `thinking` text and a `signature` | Claude 3.7 returned the full thinking. Claude 4 models return a summary of it. |
| `redacted_thinking` | An encrypted `data` string | Returned instead of readable thinking when the reasoning was flagged by safety systems. |
| `text` | The final answer | Always present on a normal completion. |
You are billed for the full thinking tokens, not for the summarized text you receive. The output_tokens count in usage therefore will not match the number of tokens in the visible blocks. The first block types are shown in this code:
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=4096,
thinking={"type": "enabled", "budget_tokens": 2000},
messages=[
{"role": "user", "content": "Is 3599 a prime number? Explain briefly."}
],
)
for block in response.content:
if block.type == "thinking":
print("[thinking]", block.thinking)
elif block.type == "redacted_thinking":
print("[thinking] (redacted, %d characters of encrypted data)" % len(block.data))
elif block.type == "text":
print("[answer]", block.text)
print("output tokens billed:", response.usage.output_tokens)Always handle redacted_thinking. A loop that only checks for thinking and text will silently drop it. For a single request that is harmless, but in a multi-turn flow, discussed below, dropping a block breaks the next request.
Streaming thinking
When you stream, thinking arrives before the answer. In the Anthropic stream, a content_block_start event announces a block of type thinking, then content_block_delta events carry a thinking_delta. Later, the text block streams text_delta events. The signature arrives in a signature_delta event at the end of the thinking block.
For the user interface, this gives you a choice:
- Show thinking live, in a collapsed panel, so the user sees progress during a long wait.
- Hide thinking and show only a "working" indicator until the first text delta arrives.
Either way, the time to the first visible answer token includes all the thinking time. Streaming the thinking improves perceived latency, but it does not reduce actual latency.
Passing reasoning back in later turns
Reasoning matters again when your application calls tools or continues a conversation. The two providers handle this differently.
Anthropic. When the model uses a tool during extended thinking, you must send the assistant turn back unchanged, including its thinking and redacted_thinking blocks, together with the tool result. The signature lets the API check that the block was not edited. If you modify, reorder or drop the blocks, the request can be rejected. For ordinary turns without tools, earlier thinking blocks are removed from the context by the API and do not count as input tokens in later turns.
OpenAI. Reasoning items can be carried between turns so that the model keeps its earlier reasoning when it makes function calls. There are two ways to do this:
- Chain requests with
previous_response_id, and the server keeps the reasoning for you. - Manage state yourself. This is needed when you set
store=Falseor when your organization requires zero data retention. Requestinclude=["reasoning.encrypted_content"], and append the returned reasoning items to your nextinputlist.
The encrypted content is opaque. You cannot read it, and you should not try to edit it.
from openai import OpenAI
client = OpenAI()
history = [{"role": "user", "content": "Plan three steps to migrate a table with no downtime."}]
first = client.responses.create(
model="o4-mini",
reasoning={"effort": "low"},
input=history,
store=False,
include=["reasoning.encrypted_content"],
)
# Carry every output item, including reasoning items, into the next turn.
history += first.output
history.append({"role": "user", "content": "Now list the main risk in step two."})
second = client.responses.create(
model="o4-mini",
reasoning={"effort": "low"},
input=history,
store=False,
include=["reasoning.encrypted_content"],
)
print(second.output_text)What the visible reasoning is good for
Summaries and thinking blocks are useful, within limits:
- Debugging prompts. If the model misread the task, the summary often shows which part it misread.
- Spotting tool problems. You can see that the model planned to call a tool and why.
- Building trust in a user interface. A short "what I considered" section helps users judge an answer.
- Cost diagnosis. A long summary on a trivial question suggests the effort setting is too high for that task.
What the visible reasoning is not
Treat the following as rules.
- It is not a complete log. A summary leaves things out by design, and it may be reworded. Do not parse it for exact intermediate values.
- It is not guaranteed to explain the answer. The reasoning that the model displays may not fully reflect what drove its output. Do not use it as proof that an answer is correct, and do not build an audit trail on it.
- It is not stable. Format, length and availability can change between model versions. Code that depends on a specific phrase in a summary will break.
- It is not always safe to show. Reasoning can contain fragments of user data, system instructions or tool output. Apply the same logging, retention and redaction rules as for the final answer.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| `summary` list is empty | Model skipped the summary, the model does not support it, or the organization is not verified | Handle the empty case and check the model's documentation |
| Request rejected after a tool call with extended thinking | Thinking blocks were dropped or edited | Return the assistant content exactly as received |
| Visible tokens far below billed output tokens | Normal. You pay for the raw reasoning, not the summary | Read `usage`, not the text length |
| Code crashes on an unexpected block type | Loop assumes only `thinking` and `text` | Add a branch for `redacted_thinking` and a default case |
| Reasoning text appears in logs | Whole response object was logged | Log only the fields you need |
Summary of the main differences
| Question | OpenAI Responses API | Anthropic Messages API |
|---|---|---|
| How do I ask for visible reasoning? | `reasoning={"summary": "auto"}` | `thinking={"type": "enabled", "budget_tokens": N}` |
| Where does it appear? | Items with `type == "reasoning"` in `output` | Blocks with `type == "thinking"` in `content` |
| Is raw reasoning readable? | No. Only a summary | Full on Claude 3.7. A summary on Claude 4 models |
| What is billed? | Full reasoning tokens | Full thinking tokens |
| What must I send back with tools? | Reasoning items, by ID or as encrypted content | Thinking blocks, unchanged, with their signatures |
Exercise
A request to a reasoning model returns a three-sentence summary of its thinking, and usage reports 6,000 output tokens, of which 5,400 are reasoning tokens. A teammate says the bill should be based on the roughly 150 tokens of visible text. Is the teammate right? Name one thing your code must do if this model is used with tool calls and extended thinking.
Show answer
The teammate is wrong. Providers bill for the full reasoning that the model generated, here 5,400 reasoning tokens plus the answer tokens, not for the shorter summary. When extended thinking is combined with tool calls on the Anthropic API, the code must send the assistant's thinking and redactedthinking blocks back unchanged (with their signatures) along with the tool result. With the OpenAI API, it must carry the reasoning items into the next request, either through previousresponse_id or by passing them in the input with encrypted content.
Exercise
Write the condition inside a loop over response.content that prevents a crash or a silent drop when the model returns a block whose reasoning was encrypted. Which block type is it, and which attribute holds its payload?
Show answer
The block type is "redactedthinking", and the payload is in its data attribute, as in `elif block.type == "redactedthinking":`. You cannot read the data, but you must keep the block and return it unchanged in later turns when tools are in use.