What are reasoning models and "extended thinking"?

Learning path, stage 2 of 5: Prompting and model features · question 9 of 10

Reasoning models are trained, largely with reinforcement learning on tasks whose answers can be checked, to produce a long internal chain of thought before answering. APIs expose this as "thinking": the model plans, tries approaches and checks its work in thinking blocks, then writes the answer. You trade latency and tokens for accuracy on hard problems.

How you control it

  • Older APIs had a fixed thinking-token budget. Newer ones use adaptive thinking: the model decides how much to think, and you set an effort level (low → max) for the overall depth and token spend.
  • Thinking tokens are billed as output, even when the API hides or summarises them.
  • In agent loops, models can think between tool calls and reason about each result before the next step.

When to use more effort

  • Hard maths, tricky debugging, planning, long multi-step agent tasks: higher effort.
  • Chat, classification, simple extraction: low effort. Extra thinking just adds cost and latency.
  • Measure. Raise effort only where your evals show a gain.

Prompting differences

  • Give the goal and the constraints, not step-by-step scripts. Rigid instructions can make results worse.
  • You don't need "think step by step". The model already reasons.

Sources

Code example

tsx
1// Adaptive thinking with an effort level, plus a readable thinking summary.
2import Anthropic from "@anthropic-ai/sdk";
3
4const client = new Anthropic();
5
6const res = await client.messages.create({
7 model: "claude-opus-5-5",
8 max_tokens: 16000,
9 thinking: { type: "adaptive", display: "summarized" },
10 output_config: { effort: "high" }, // low | medium | high | xhigh | max
11 messages: [
12 { role: "user", content: "Find the bug: function avg(a) { return a.reduce((s,x)=>s+x) / a.length }" },
13 ],
14});
15
16for (const block of res.content) {
17 if (block.type === "thinking") console.log("Thinking summary:", block.thinking);
18 if (block.type === "text") console.log("Answer:", block.text);
19}
20console.log("Output tokens (incl. thinking):", res.usage.output_tokens);

To run it: follow the one-time setup guide, add npm i @anthropic-ai/sdk zod, save the code as a .ts file and run npx tsx file.ts. Anything marked declare is a part you supply.

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the AI Agents & LLMs set.

Open in study app