Mastering Extended Thinking in Claude: A Practical Guide to Adaptive and Manual Reasoning
Learn how to enable and optimize Claude's extended thinking for complex reasoning tasks. Covers adaptive thinking, manual mode, effort parameters, and code examples for the API.
This guide explains how to use Claude's extended thinking feature to get step-by-step reasoning before final answers. You'll learn the difference between adaptive and manual thinking, how to set effort levels, and see practical API code examples for Python and TypeScript.
Introduction
Claude's extended thinking feature unlocks a new level of reasoning capability. When enabled, Claude outputs its internal thought process as separate "thinking" content blocks before delivering its final answer. This gives you both transparency into how Claude arrives at conclusions and significantly improved accuracy on complex tasks like mathematics, logic puzzles, code analysis, and multi-step planning.
This guide covers everything you need to know to use extended thinking effectively in the Claude API, including the latest adaptive thinking mode introduced with Claude Opus 4.7.
How Extended Thinking Works
When extended thinking is turned on, the API response includes one or more thinking content blocks followed by text content blocks. Each thinking block contains Claude's internal reasoning and a cryptographic signature for verification.
Example response structure:
{
"content": [
{
"type": "thinking",
"thinking": "Let me analyze this step by step...",
"signature": "WaUjzkypQ2mUEVM36O2TxuC06KN8xyfbJwyem2dw3URve/op91XWHOEBLLqIOMfFG/UvLEczmEsUjavL...."
},
{
"type": "text",
"text": "Based on my analysis..."
}
]
}
The thinking blocks are not shown to end users by default—they are available for you to inspect, log, or display as you see fit.
Adaptive Thinking vs. Manual Extended Thinking
Claude offers two modes for extended thinking:
Adaptive Thinking (Recommended)
Adaptive thinking lets Claude automatically decide how much thinking to perform based on the complexity of the task. You simply set an effort level, and Claude allocates tokens dynamically. This is the only supported mode on Claude Opus 4.7 and is strongly recommended for all other models. Effort levels:"low"– Minimal reasoning, fastest responses"medium"– Balanced reasoning and speed"high"– Deep reasoning, best for complex problems
Manual Extended Thinking (Deprecated)
Manual extended thinking requires you to specify abudget_tokens value—the maximum number of tokens Claude can use for thinking. This mode is deprecated on Claude Opus 4.6 and Claude Sonnet 4.6, and no longer supported on Claude Opus 4.7 (returns a 400 error).
| Model | Adaptive Thinking | Manual Thinking |
|---|---|---|
| Claude Opus 4.7 | ✅ Required | ❌ Returns 400 error |
| Claude Opus 4.6 | ✅ Recommended | ⚠️ Deprecated but functional |
| Claude Sonnet 4.6 | ✅ Recommended | ⚠️ Deprecated but functional |
| Claude Mythos Preview | ✅ Default | ✅ Accepted |
Using Extended Thinking in the API
Adaptive Thinking with Effort (Recommended)
Here's how to use adaptive thinking with the effort parameter:
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-4-7",
max_tokens=16000,
thinking={
"type": "adaptive",
"effort": "high"
},
messages=[
{
"role": "user",
"content": "Prove that the square root of 2 is irrational."
}
]
)
for block in response.content:
if block.type == "thinking":
print(f"Thinking: {block.thinking}")
elif block.type == "text":
print(f"Answer: {block.text}")
TypeScript
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic();
const response = await client.messages.create({
model: 'claude-opus-4-7',
max_tokens: 16000,
thinking: {
type: 'adaptive',
effort: 'high'
},
messages: [
{
role: 'user',
content: 'Prove that the square root of 2 is irrational.'
}
]
});
for (const block of response.content) {
if (block.type === 'thinking') {
console.log(Thinking: ${block.thinking});
} else if (block.type === 'text') {
console.log(Answer: ${block.text});
}
}
Manual Extended Thinking (Legacy)
If you're using a model that still supports manual mode (e.g., Claude Sonnet 4.6), the syntax is:
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=16000,
thinking={
"type": "enabled",
"budget_tokens": 10000
},
messages=[
{
"role": "user",
"content": "Are there an infinite number of prime numbers such that n mod 4 == 3?"
}
]
)
Best Practices
1. Choose the Right Effort Level
- Low effort: Use for simple tasks where speed matters, like basic Q&A or straightforward data extraction.
- Medium effort: Good for most analytical tasks—code review, moderate math, logical reasoning.
- High effort: Reserve for complex multi-step problems, mathematical proofs, strategic planning, or tasks requiring deep reasoning.
2. Set Appropriate max_tokens
Your max_tokens value must be greater than the thinking budget. A good rule of thumb is to set max_tokens to 1.5x to 2x your expected thinking usage. For adaptive thinking, start with max_tokens=16000 and adjust based on your use case.
3. Handle Thinking Blocks in Streaming
When streaming, thinking blocks appear as content_block_start and content_block_delta events. You can choose to display them, log them, or skip them entirely.
4. Use for Complex Reasoning Tasks
Extended thinking shines on tasks like:
- Mathematical proofs and derivations
- Multi-step logical reasoning
- Code generation with complex logic
- Strategic planning and analysis
- Debugging intricate issues
5. Combine with Structured Outputs
You can use extended thinking alongside structured outputs (JSON mode) for tasks that require both deep reasoning and formatted responses. The thinking blocks contain the reasoning, and the final text block contains the structured output.
Differences Across Model Versions
- Claude Opus 4.7: Only supports adaptive thinking. Manual mode returns a 400 error.
- Claude Opus 4.6: Adaptive thinking recommended; manual mode deprecated but functional.
- Claude Sonnet 4.6: Adaptive thinking recommended; manual mode with interleaved mode deprecated but functional.
- Claude Mythos Preview: Adaptive thinking is the default. Manual mode is also accepted. Note that
thinking: {"type": "disabled"}is not supported, and display defaults to"omitted"rather than returning thinking content. Passdisplay: "summarized"to receive summaries.
Troubleshooting
Q: I get a 400 error when using manual thinking on Opus 4.7. A: Switch to adaptive thinking with theeffort parameter. Manual mode is not supported on this model.
Q: My response doesn't include thinking blocks.
A: Ensure you've set the thinking parameter in your request. Also check that the model supports extended thinking—older models may not.
Q: How do I know how many tokens Claude used for thinking?
A: The response usage information includes token counts. You can also monitor the length of thinking blocks.
Key Takeaways
- Use adaptive thinking with the
effortparameter for all current Claude models—it's the only option for Opus 4.7 and the recommended path forward. - Set effort levels wisely:
lowfor speed,mediumfor balance,highfor complex reasoning tasks. - Always set
max_tokenshigher than your expected thinking budget to avoid truncated responses. - Inspect thinking blocks to gain insight into Claude's reasoning process, but remember they are not shown to end users by default.
- Migrate away from manual thinking (
budget_tokens) as it is deprecated on most models and will be removed in future releases.