Claude Academy
Sign in

Vault / wiki/201/extended-thinking.md

updated 2026-05-28

Extended Thinking

"Thinking mode" — Claude produces an internal reasoning trace before its final answer. Great for hard reasoning, planning, math, code review, complex tool-use decisions.

Enabling

resp = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=8192,
    thinking={"type": "enabled", "budget_tokens": 4096},
    messages=[{"role": "user", "content": "Plan the migration..."}],
)

budget_tokens is a soft cap on thinking length; the rest of max_tokens is available for the visible answer.

Response shape

The response content array contains thinking blocks before text blocks:

"content": [
  {"type": "thinking", "thinking": "Let me consider...", "signature": "..."},
  {"type": "text", "text": "Here is the plan..."}
]

The signature is required if you pass thinking blocks back in a later turn (for tool use). Don't strip it.

When to use

  • Multi-step reasoning where Claude got it wrong without thinking.
  • Choosing between several tools or plans.
  • Code generation where correctness matters more than speed.
  • Math, logic, formal reasoning.

When NOT to use

  • High-volume cheap routing (use Haiku, no thinking).
  • Streaming UIs where first-token latency matters.
  • Tasks Claude already nails one-shot.

Thinking + tool use

When tool use is involved, you must include the prior thinking block (with its signature) in the next message, otherwise Claude loses its reasoning trace.

Redacted thinking

If Anthropic filters part of the thinking content for safety, you get a redacted_thinking block instead. Pass it back unchanged in subsequent turns.

Cost

Thinking tokens count toward output cost. A 4K thinking budget on Opus is non-trivial. Measure and tune.

See also