Was this page helpful?
Adaptive thinking è il modo consigliato per utilizzare extended thinking con Claude Opus 4.6. Invece di impostare manualmente un budget di token di thinking, adaptive thinking consente a Claude di decidere dinamicamente quando e quanto pensare in base alla complessità di ogni richiesta.
Adaptive thinking produce in modo affidabile prestazioni migliori rispetto a extended thinking con un budget_tokens fisso, e consigliamo di passare a adaptive thinking per ottenere le risposte più intelligenti da Opus 4.6. Non è richiesta alcuna intestazione beta.
Adaptive thinking è supportato sui seguenti modelli:
claude-opus-4-6)thinking.type: "enabled" e budget_tokens sono deprecati su Opus 4.6 e verranno rimossi in una futura versione del modello. Utilizza thinking.type: "adaptive" con il parametro effort invece.
I modelli più vecchi (Sonnet 4.5, Opus 4.5, ecc.) non supportano adaptive thinking e richiedono thinking.type: "enabled" con budget_tokens.
In modalità adaptive, il thinking è facoltativo per il modello. Claude valuta la complessità di ogni richiesta e decide se e quanto pensare. Al livello di effort predefinito (high), Claude penserà quasi sempre. A livelli di effort inferiori, Claude potrebbe saltare il thinking per problemi più semplici.
Adaptive thinking abilita anche automaticamente interleaved thinking. Ciò significa che Claude può pensare tra le chiamate ai tool, rendendolo particolarmente efficace per i flussi di lavoro agentic.
Imposta thinking.type su "adaptive" nella tua richiesta API:
Puoi combinare adaptive thinking con il parametro effort per guidare quanto Claude pensa. Il livello di effort agisce come una guida soft per l'allocazione del thinking di Claude:
| Livello di effort | Comportamento del thinking |
|---|---|
max | Claude pensa sempre senza vincoli sulla profondità del thinking. Solo Opus 4.6 — le richieste che utilizzano max su altri modelli restituiranno un errore. |
high (predefinito) | Claude pensa sempre. Fornisce ragionamento profondo su compiti complessi. |
medium | Claude utilizza un thinking moderato. Potrebbe saltare il thinking per query molto semplici. |
low | Claude minimizza il thinking. Salta il thinking per compiti semplici dove la velocità è più importante. |
Adaptive thinking funziona perfettamente con streaming. I blocchi di thinking vengono trasmessi tramite eventi thinking_delta proprio come in modalità thinking manuale:
| Modalità | Configurazione | Disponibilità | Quando utilizzare |
|---|---|---|---|
| Adaptive | thinking: {type: "adaptive"} | Opus 4.6 | Claude decide quando e quanto pensare. Utilizza effort per guidare. |
| Manual | thinking: {type: "enabled", budget_tokens: N} | Tutti i modelli. Deprecato su Opus 4.6 — utilizza la modalità adaptive invece. | Quando hai bisogno di un controllo preciso sulla spesa di token di thinking. |
| Disabled | Ometti il parametro thinking | Tutti i modelli | Quando non hai bisogno di extended thinking e desideri la latenza più bassa. |
Adaptive thinking è attualmente disponibile su Opus 4.6. I modelli più vecchi supportano solo type: "enabled" con budget_tokens. Su Opus 4.6, type: "enabled" con budget_tokens è ancora accettato ma deprecato — consigliamo di utilizzare adaptive thinking con il parametro effort invece.
Quando si utilizza adaptive thinking, i turni dell'assistente precedenti non devono iniziare con blocchi di thinking. Questo è più flessibile rispetto alla modalità manuale, dove l'API applica che i turni con thinking abilitato inizino con un blocco di thinking.
Le richieste consecutive che utilizzano adaptive thinking preservano i breakpoint della prompt cache. Tuttavia, il passaggio tra le modalità di thinking adaptive e enabled/disabled interrompe i breakpoint della cache per i messaggi. I prompt di sistema e le definizioni dei tool rimangono in cache indipendentemente dai cambiamenti di modalità.
Il comportamento di attivazione di adaptive thinking è promptable. Se Claude sta pensando più o meno spesso di quanto desideri, puoi aggiungere una guida al tuo prompt di sistema:
Extended thinking adds latency and should only be used when it
will meaningfully improve answer quality — typically for problems
that require multi-step reasoning. When in doubt, respond directly.Indirizzare Claude a pensare meno spesso potrebbe ridurre la qualità su compiti che beneficiano dal ragionamento. Misura l'impatto sui tuoi carichi di lavoro specifici prima di distribuire il tuning basato su prompt in produzione. Considera di testare prima con livelli di effort inferiori.
Utilizza max_tokens come limite rigido sull'output totale (thinking + testo di risposta). Il parametro effort fornisce una guida soft aggiuntiva su quanto thinking Claude alloca. Insieme, questi ti danno un controllo efficace sui costi.
Ai livelli di effort high e max, Claude potrebbe pensare più estesamente e potrebbe essere più probabile che esaurisca il budget di max_tokens. Se osservi stop_reason: "max_tokens" nelle risposte, considera di aumentare max_tokens per dare al modello più spazio, o abbassare il livello di effort.
I seguenti concetti si applicano a tutti i modelli che supportano extended thinking, indipendentemente dal fatto che tu utilizzi la modalità adaptive o manuale.
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:
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.
Full thinking content is encrypted and returned in the signature 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.
Here are some important considerations on thinking encryption:
signature_delta inside a content_block_delta event just before the content_block_stop event.signature values are significantly longer in Claude 4 models than in previous models.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.Occasionally Claude's internal reasoning will be flagged by our safety systems. When this occurs, we encrypt some or all of the thinking 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:
Here's an example showing both normal and redacted thinking blocks:
{
"content": [
{
"type": "thinking",
"thinking": "Let me analyze this step by step...",
"signature": "WaUjzkypQ2mUEVM36O2TxuC06KN8xyfbJwyem2dw3URve/op91XWHOEBLLqIOMfFG/UvLEczmEsUjavL...."
},
{
"type": "redacted_thinking",
"data": "EmwKAhgBEgy3va3pzix/LafPsn4aDFIT2Xlxh0L5L8rLVyIwxtE3rAFBa8cr3qpPkNRj2YfWXGmKDxH4mPnZ5sQ7vB9URj2pLmN3kF8/dW5hR7xJ0aP1oLs9yTcMnKVf2wRpEGjH9XZaBt4UvDcPrQ..."
},
{
"type": "text",
"text": "Based on my analysis..."
}
]
}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
When passing 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.
For complete pricing information including base rates, cache writes, cache hits, and output tokens, see the pricing page.
The thinking process incurs charges for:
When extended thinking is enabled, a specialized system prompt is automatically included to support this feature.
When using summarized thinking:
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.
La pagina extended thinking copre diversi argomenti in più dettaglio con esempi di codice specifici della modalità:
tool_choice quando il thinking è attivo.adaptive e enabled/disabled interrompe i breakpoint della cache per i messaggi (i prompt di sistema e le definizioni dei tool rimangono in cache).max_tokens e i limiti della finestra di contesto.curl https://api.anthropic.com/v1/messages \
--header "x-api-key: $ANTHROPIC_API_KEY" \
--header "anthropic-version: 2023-06-01" \
--header "content-type: application/json" \
--data \
'{
"model": "claude-opus-4-6",
"max_tokens": 16000,
"thinking": {
"type": "adaptive"
},
"messages": [
{
"role": "user",
"content": "Explain why the sum of two even numbers is always even."
}
]
}'import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-4-6",
max_tokens=16000,
thinking={
"type": "adaptive"
},
output_config={
"effort": "medium"
},
messages=[{
"role": "user",
"content": "What is the capital of France?"
}]
)
print(response.content[0].text)import anthropic
client = anthropic.Anthropic()
with client.messages.stream(
model="claude-opus-4-6",
max_tokens=16000,
thinking={"type": "adaptive"},
messages=[{"role": "user", "content": "What is the greatest common divisor of 1071 and 462?"}],
) as stream:
for event in stream:
if event.type == "content_block_start":
print(f"\nStarting {event.content_block.type} block...")
elif event.type == "content_block_delta":
if event.delta.type == "thinking_delta":
print(event.delta.thinking, end="", flush=True)
elif event.delta.type == "text_delta":
print(event.delta.text, end="", flush=True)Scopri di più su extended thinking, inclusa la modalità manuale, l'uso dei tool e il prompt caching.