Supported models
Extended thinking is supported in the following models:- Claude Opus 4.1 (
claude-opus-4-1-20250805
) - Claude Opus 4 (
claude-opus-4-20250514
) - Claude Sonnet 4 (
claude-sonnet-4-20250514
) - Claude Sonnet 3.7 (
claude-3-7-sonnet-20250219
)
API behavior differs across Claude Sonnet 3.7 and Claude 4 models, but the API shapes remain exactly the same.For more information, see Differences in thinking across model versions.
How extended thinking works
When extended thinking is turned on, Claude createsthinking
content blocks where it outputs its internal reasoning. Claude incorporates insights from this reasoning before crafting a final response.
The API response will include thinking
content blocks, followed by text
content blocks.
Here’s an example of the default response format:
How to use extended thinking
Here is an example of using extended thinking in the Messages API:thinking
object, with the type
parameter set to enabled
and the budget_tokens
to a specified token budget for extended thinking.
The budget_tokens
parameter determines the maximum number of tokens Claude is allowed to use for its internal reasoning process. In Claude 4 models, this limit applies to full thinking tokens, and not to the summarized output. Larger budgets can improve response quality by enabling more thorough analysis for complex problems, although Claude may not use the entire budget allocated, especially at ranges above 32k.
budget_tokens
must be set to a value less than max_tokens
. However, when using interleaved thinking with tools, you can exceed this limit as the token limit becomes your entire context window (200k tokens).
Summarized thinking
With extended thinking enabled, the Messages API for Claude 4 models returns a summary of Claude’s full thinking process. Summarized thinking provides the full intelligence benefits of extended thinking, while preventing misuse. Here are some important considerations for summarized thinking:- You’re charged for the full thinking tokens generated by the original request, not the summary tokens.
- The billed output token count will not match the count of tokens you see in the response.
- The first few lines of thinking output are more verbose, providing detailed reasoning that’s particularly helpful for prompt engineering purposes.
- As Anthropic seeks to improve the extended thinking feature, summarization behavior is subject to change.
- Summarization preserves the key ideas of Claude’s thinking process with minimal added latency, enabling a streamable user experience and easy migration from Claude Sonnet 3.7 to Claude 4 models.
- Summarization is processed by a different model than the one you target in your requests. The thinking model does not see the summarized output.
Claude Sonnet 3.7 continues to return full thinking output.In rare cases where you need access to full thinking output for Claude 4 models, contact our sales team.
Streaming thinking
You can stream extended thinking responses using server-sent events (SSE). When streaming is enabled for extended thinking, you receive thinking content viathinking_delta
events.
For more documention on streaming via the Messages API, see Streaming Messages.
Here’s how to handle streaming with thinking:
When using streaming with thinking enabled, you might notice that text sometimes arrives in larger chunks alternating with smaller, token-by-token delivery. This is expected behavior, especially for thinking content.The streaming system needs to process content in batches for optimal performance, which can result in this “chunky” delivery pattern, with possible delays between streaming events. We’re continuously working to improve this experience, with future updates focused on making thinking content stream more smoothly.
Extended thinking with tool use
Extended thinking can be used alongside tool use, allowing Claude to reason through tool selection and results processing. When using extended thinking with tool use, be aware of the following limitations:-
Tool choice limitation: Tool use with thinking only supports
tool_choice: {"type": "auto"}
(the default) ortool_choice: {"type": "none"}
. Usingtool_choice: {"type": "any"}
ortool_choice: {"type": "tool", "name": "..."}
will result in an error because these options force tool use, which is incompatible with extended thinking. -
Preserving thinking blocks: During tool use, you must pass
thinking
blocks back to the API for the last assistant message. Include the complete unmodified block back to the API to maintain reasoning continuity.
Example: Passing thinking blocks with tool results
Example: Passing thinking blocks with tool results
Here’s a practical example showing how to preserve thinking blocks when providing tool results:The API response will include thinking, text, and tool_use blocks:Now let’s continue the conversation and use the toolThe API response will now only include text
Preserving thinking blocks
During tool use, you must passthinking
blocks back to the API, and you must include the complete unmodified block back to the API. This is critical for maintaining the model’s reasoning flow and conversation integrity.
While you can omit
thinking
blocks from prior assistant
role turns, we suggest always passing back all thinking blocks to the API for any multi-turn conversation. The API will:- Automatically filter the provided thinking blocks
- Use the relevant thinking blocks necessary to preserve the model’s reasoning
- Only bill for the input tokens for the blocks shown to Claude
- Reasoning continuity: The thinking blocks capture Claude’s step-by-step reasoning that led to tool requests. When you post tool results, including the original thinking ensures Claude can continue its reasoning from where it left off.
- Context maintenance: While tool results appear as user messages in the API structure, they’re part of a continuous reasoning flow. Preserving thinking blocks maintains this conceptual flow across multiple API calls. For more information on context management, see our guide on context windows.
thinking
blocks, the entire sequence of consecutive thinking
blocks must match the outputs generated by the model during the original request; you cannot rearrange or modify the sequence of these blocks.
Interleaved thinking
Extended thinking with tool use in Claude 4 models supports interleaved thinking, which enables Claude to think between tool calls and make more sophisticated reasoning after receiving tool results. With interleaved thinking, Claude can:- Reason about the results of a tool call before deciding what to do next
- Chain multiple tool calls with reasoning steps in between
- Make more nuanced decisions based on intermediate results
interleaved-thinking-2025-05-14
to your API request.
Here are some important considerations for interleaved thinking:
- With interleaved thinking, the
budget_tokens
can exceed themax_tokens
parameter, as it represents the total budget across all thinking blocks within one assistant turn. - Interleaved thinking is only supported for tools used via the Messages API.
- Interleaved thinking is supported for Claude 4 models only, with the beta header
interleaved-thinking-2025-05-14
. - Direct calls to the Claude API allow you to pass
interleaved-thinking-2025-05-14
in requests to any model, with no effect. - On 3rd-party platforms (e.g., Amazon Bedrock and Vertex AI), if you pass
interleaved-thinking-2025-05-14
to any model aside from Claude Opus 4.1, Opus 4, or Sonnet 4, your request will fail.
Tool use without interleaved thinking
Tool use without interleaved thinking
- Claude thinks once at the beginning to understand the task
- Makes all tool use decisions upfront
- When tool results are returned, Claude immediately provides a response without additional thinking
Tool use with interleaved thinking
Tool use with interleaved thinking
- Claude thinks about the task initially
- After receiving the calculator result, Claude can think again about what that result means
- Claude then decides how to query the database based on the first result
- After receiving the database result, Claude thinks once more about both results before formulating a final response
- The thinking budget is distributed across all thinking blocks within the turn
Extended thinking with prompt caching
Prompt caching with thinking has several important considerations:Extended thinking tasks often take longer than 5 minutes to complete. Consider using the 1-hour cache duration to maintain cache hits across longer thinking sessions and multi-step workflows.
- Thinking blocks from previous turns are removed from context, which can affect cache breakpoints
- When continuing conversations with tool use, thinking blocks are cached and count as input tokens when read from cache
- This creates a tradeoff: while thinking blocks don’t consume context window space visually, they still count toward your input token usage when cached
- If thinking becomes disabled, requests will fail if you pass thinking content in the current tool use turn. In other contexts, thinking content passed to the API is simply ignored
- Changes to thinking parameters (enabled/disabled or budget allocation) invalidate message cache breakpoints
- Interleaved thinking amplifies cache invalidation, as thinking blocks can occur between multiple tool calls
- System prompts and tools remain cached despite thinking parameter changes or block removal
While thinking blocks are removed for caching and context calculations, they must be preserved when continuing conversations with tool use, especially with interleaved thinking.
Understanding thinking block caching behavior
When using extended thinking with tool use, thinking blocks exhibit specific caching behavior that affects token counting: How it works:- Caching only occurs when you make a subsequent request that includes tool results
- When the subsequent request is made, the previous conversation history (including thinking blocks) can be cached
- These cached thinking blocks count as input tokens in your usage metrics when read from the cache
- When a non-tool-result user block is included, all previous thinking blocks are ignored and stripped from context
- This caching behavior happens automatically, even without explicit
cache_control
markers - This behavior is consistent whether using regular thinking or interleaved thinking
System prompt caching (preserved when thinking changes)
System prompt caching (preserved when thinking changes)
Messages caching (invalidated when thinking changes)
Messages caching (invalidated when thinking changes)
cache_creation_input_tokens=1370
and cache_read_input_tokens=0
, proving that message-based caching is invalidated when thinking parameters change.Max tokens and context window size with extended thinking
In older Claude models (prior to Claude Sonnet 3.7), if the sum of prompt tokens andmax_tokens
exceeded the model’s context window, the system would automatically adjust max_tokens
to fit within the context limit. This meant you could set a large max_tokens
value and the system would silently reduce it as needed.
With Claude 3.7 and 4 models, max_tokens
(which includes your thinking budget when thinking is enabled) is enforced as a strict limit. The system will now return a validation error if prompt tokens + max_tokens
exceeds the context window size.
You can read through our guide on context windows for a more thorough deep dive.
The context window with extended thinking
When calculating context window usage with thinking enabled, there are some considerations to be aware of:- Thinking blocks from previous turns are stripped and not counted towards your context window
- Current turn thinking counts towards your
max_tokens
limit for that turn
The context window with extended thinking and tool use
When using extended thinking with tool use, thinking blocks must be explicitly preserved and returned with the tool results. The effective context window calculation for extended thinking with tool use becomes:Managing tokens with extended thinking
Given the context window andmax_tokens
behavior with extended thinking Claude 3.7 and 4 models, you may need to:
- More actively monitor and manage your token usage
- Adjust
max_tokens
values as your prompt length changes - Potentially use the token counting endpoints more frequently
- Be aware that previous thinking blocks don’t accumulate in your context window
Thinking encryption
Full thinking content is encrypted and returned in thesignature
field. This field is used to verify that thinking blocks were generated by Claude when passed back to the API.
It is only strictly necessary to send back thinking blocks when using tools with extended thinking. Otherwise you can omit thinking blocks from previous turns, or let the API strip them for you if you pass them back.If sending back thinking blocks, we recommend passing everything back as you received it for consistency and to avoid potential issues.
- When streaming responses, the signature is added via a
signature_delta
inside acontent_block_delta
event just before thecontent_block_stop
event. signature
values are significantly longer in Claude 4 models than in previous models.- The
signature
field is an opaque field and should not be interpreted or parsed - it exists solely for verification purposes. signature
values are compatible across platforms (Claude APIs, Amazon Bedrock, and Vertex AI). Values generated on one platform will be compatible with another.
Thinking redaction
Occasionally Claude’s internal reasoning will be flagged by our safety systems. When this occurs, we encrypt some or all of thethinking
block and return it to you as a redacted_thinking
block. redacted_thinking
blocks are decrypted when passed back to the API, allowing Claude to continue its response without losing context.
When building customer-facing applications that use extended thinking:
- Be aware that redacted thinking blocks contain encrypted content that isn’t human-readable
- Consider providing a simple explanation like: “Some of Claude’s internal reasoning has been automatically encrypted for safety reasons. This doesn’t affect the quality of responses.”
- If showing thinking blocks to users, you can filter out redacted blocks while preserving normal thinking blocks
- Be transparent that using extended thinking features may occasionally result in some reasoning being encrypted
- Implement appropriate error handling to gracefully manage redacted thinking without breaking your UI
Seeing redacted thinking blocks in your output is expected behavior. The model can still use this redacted reasoning to inform its responses while maintaining safety guardrails.If you need to test redacted thinking handling in your application, you can use this special test string as your prompt:
ANTHROPIC_MAGIC_STRING_TRIGGER_REDACTED_THINKING_46C9A13E193C177646C7398A98432ECCCE4C1253D5E2D82641AC0E52CC2876CB
thinking
and redacted_thinking
blocks back to the API in a multi-turn conversation, you must include the complete unmodified block back to the API for the last assistant turn. This is critical for maintaining the model’s reasoning flow. We suggest always passing back all thinking blocks to the API. For more details, see the Preserving thinking blocks section above.
Example: Working with redacted thinking blocks
Example: Working with redacted thinking blocks
This example demonstrates how to handle
redacted_thinking
blocks that may appear in responses when Claude’s internal reasoning contains content flagged by safety systems:Differences in thinking across model versions
The Messages API handles thinking differently across Claude Sonnet 3.7 and Claude 4 models, primarily in redaction and summarization behavior. See the table below for a condensed comparison:Feature | Claude Sonnet 3.7 | Claude 4 Models |
---|---|---|
Thinking Output | Returns full thinking output | Returns summarized thinking |
Interleaved Thinking | Not supported | Supported with interleaved-thinking-2025-05-14 beta header |
Pricing
Extended thinking uses the standard token pricing scheme:Model | Base Input Tokens | Cache Writes | Cache Hits | Output Tokens |
---|---|---|---|---|
Claude Opus 4.1 | $15 / MTok | $18.75 / MTok | $1.50 / MTok | $75 / MTok |
Claude Opus 4 | $15 / MTok | $18.75 / MTok | $1.50 / MTok | $75 / MTok |
Claude Sonnet 4 | $3 / MTok | $3.75 / MTok | $0.30 / MTok | $15 / MTok |
Claude Sonnet 3.7 | $3 / MTok | $3.75 / MTok | $0.30 / MTok | $15 / MTok |
- Tokens used during thinking (output tokens)
- Thinking blocks from the last assistant turn included in subsequent requests (input tokens)
- Standard text output tokens
When extended thinking is enabled, a specialized system prompt is automatically included to support this feature.
- Input tokens: Tokens in your original request (excludes thinking tokens from previous turns)
- Output tokens (billed): The original thinking tokens that Claude generated internally
- Output tokens (visible): The summarized thinking tokens you see in the response
- No charge: Tokens used to generate the summary
The billed output token count will not match the visible token count in the response. You are billed for the full thinking process, not the summary you see.
Best practices and considerations for extended thinking
Working with thinking budgets
- Budget optimization: The minimum budget is 1,024 tokens. We suggest starting at the minimum and increasing the thinking budget incrementally to find the optimal range for your use case. Higher token counts enable more comprehensive reasoning but with diminishing returns depending on the task. Increasing the budget can improve response quality at the tradeoff of increased latency. For critical tasks, test different settings to find the optimal balance. Note that the thinking budget is a target rather than a strict limit—actual token usage may vary based on the task.
- Starting points: Start with larger thinking budgets (16k+ tokens) for complex tasks and adjust based on your needs.
- Large budgets: For thinking budgets above 32k, we recommend using batch processing to avoid networking issues. Requests pushing the model to think above 32k tokens causes long running requests that might run up against system timeouts and open connection limits.
- Token usage tracking: Monitor thinking token usage to optimize costs and performance.
Performance considerations
- Response times: Be prepared for potentially longer response times due to the additional processing required for the reasoning process. Factor in that generating thinking blocks may increase overall response time.
- Streaming requirements: Streaming is required when
max_tokens
is greater than 21,333. When streaming, be prepared to handle both thinking and text content blocks as they arrive.
Feature compatibility
- Thinking isn’t compatible with
temperature
ortop_k
modifications as well as forced tool use. - When thinking is enabled, you can set
top_p
to values between 1 and 0.95. - You cannot pre-fill responses when thinking is enabled.
- Changes to the thinking budget invalidate cached prompt prefixes that include messages. However, cached system prompts and tool definitions will continue to work when thinking parameters change.
Usage guidelines
- Task selection: Use extended thinking for particularly complex tasks that benefit from step-by-step reasoning like math, coding, and analysis.
- Context handling: You do not need to remove previous thinking blocks yourself. The Claude API automatically ignores thinking blocks from previous turns and they are not included when calculating context usage.
- Prompt engineering: Review our extended thinking prompting tips if you want to maximize Claude’s thinking capabilities.