Skip to main content

Extended Thinking & Effort

Intermediate

For hard problems, Claude can spend extra compute thinking before it answers — improving accuracy on multi-step reasoning, tricky code, and math. You control roughly how much effort to spend. This lesson teaches you to match depth to the task, turn thinking on via the API, and budget it without overpaying.

What you'll learn
  • Explain the trade-off: less thinking is faster and cheaper, more thinking is better on hard problems
  • Pick the right effort tier (Low / Medium / High) for a given workload
  • Enable extended thinking on the Messages API and read back the thinking and text blocks
  • Budget thinking tokens correctly so budget_tokens stays below max_tokens
  • Apply effort wisely in agents and alongside chain-of-thought prompting

The one idea behind effort

Thinking is a dial, not a switch. Picture the two ends:

  • Less thinking = faster, cheaper — fine for simple, well-specified tasks.
  • More thinking = better on genuinely hard problems, at higher latency/cost.

Here's the catch that trips people up: extra thinking does nothing for a task that was already easy. You only pay the latency and cost. The skill is spending depth where it changes the answer.

Newer models expose this as an effort control (and adapt thinking depth automatically); on those, you choose a tier rather than a raw token budget. Match the tier to the task.

Step 1 — Choose your depth

Before you touch any code, ask: how hard is this task, really? Map it to a tier.

TaskSuggested effort
Formatting, extraction, simple Q&ALow
Everyday coding, drafting, analysisMedium
Hard debugging, tricky algorithms, careful proofsHigh
Pro tip
  • Don't default everything to maximum — you pay in latency and cost for thinking the task doesn't need.
  • Start medium; raise it only where quality demands.

Try it yourself: before reading on, classify these three — (a) "extract the email from this text", (b) "refactor this function", (c) "prove this inequality". Which tier fits each? Check your answers against the table above.

Step 2 — Turn it on (API)

On the Messages API, enable thinking with a thinking block and a token budget. Follow these steps.

Guided walkthrough1 of 3
  1. Pass thinking={"type": "enabled", "budget_tokens": N} on messages.create to enable extended reasoning.

Now wire it up. Copy this, run it, and watch the reply arrive as two blocks — the reasoning first, then the answer.

Enable extended thinking (Python)

import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
  model="claude-sonnet-5",
  max_tokens=16000,
  thinking={"type": "enabled", "budget_tokens": 10000},
  messages=[{"role": "user", "content": "Prove that 2^n > n^2 for all n >= 5."}],
)

for block in message.content:
  if block.type == "thinking":
      print("REASONING:", block.thinking)
  elif block.type == "text":
      print("ANSWER:", block.text)

A bigger budget buys more room to reason, not a guarantee Claude uses all of it — depth adapts to the problem. Set the budget like a ceiling, then tune down if latency hurts. Model IDs come from the models table; the exact parameter shape can differ on newer models, so confirm against the source linked above.

Step 3 — Use it well in practice

Three habits separate people who enable thinking from people who master it:

  • Extended thinking pairs well with chain-of-thought prompting — but on reasoning models you often don't need to ask for step-by-step; the thinking happens internally.
  • Thinking consumes tokens, which affects cost — budget accordingly.
  • For agents, more effort on the planning step and less on routine tool calls is a good split.
Key takeaways
  • Effort/thinking trades latency and cost for accuracy on hard problems — it does nothing for tasks that are already simple.
  • Tiers: Low for formatting/extraction/simple Q&A, Medium for everyday coding/drafting/analysis, High for hard debugging/algorithms/proofs.
  • On the Messages API, budget_tokens comes from the same output pool, so it must be less than max_tokens; the reply is a thinking block then a text block.
  • Treat the budget as a ceiling, not a target — Claude uses only as much as the problem needs.
  • In agents, spend effort on planning and conserve it on routine tool calls.

Lock it in

Quick recall before you go — flip each card and answer out loud.

Press Enter or Space to flip the card. Use the left and right arrow keys to move between cards.Term shown.
1 / 5

Check yourself

0/5
  1. What is the core trade-off of spending more thinking effort?
  2. Which effort tier fits everyday coding, drafting, and analysis?
  3. On the Messages API, what must be true of budget_tokens?
  4. How does the reply come back when extended thinking is enabled?
  5. For agents, how should you split effort?

Next