This feature is eligible for Zero Data Retention (ZDR). When your organization has a ZDR arrangement, data sent through this feature is not stored after the API response is returned.
Adaptive thinking è il modo consigliato per utilizzare extended thinking con Claude Opus 4.7, Claude Opus 4.6 e Claude Sonnet 4.6, ed è la modalità predefinita su Claude Mythos Preview (dove si applica automaticamente quando thinking non è impostato). Invece di impostare manualmente un budget di token di pensiero, adaptive thinking consente a Claude di determinare dinamicamente quando e quanto utilizzare il pensiero esteso in base alla complessità di ogni richiesta. Su Claude Opus 4.7, adaptive thinking è l'unica modalità di pensiero supportata; il manuale thinking: {type: "enabled", budget_tokens: N} non è più accettato.
Adaptive thinking può fornire prestazioni migliori rispetto al pensiero esteso con un budget_tokens fisso per molti carichi di lavoro, specialmente per attività bimodali e flussi di lavoro agentici a lungo termine. Non è richiesta alcuna intestazione beta.
Se il tuo carico di lavoro richiede latenza prevedibile o controllo preciso sui costi del pensiero, il pensiero esteso con budget_tokens è ancora funzionale su Claude Opus 4.6 e Claude Sonnet 4.6 ma è deprecato e non è più consigliato. Vedi l'avviso di seguito.
Adaptive thinking è supportato sui seguenti modelli:
claude-mythos-preview), adaptive thinking è il predefinito; thinking: {type: "disabled"} non è supportatoclaude-opus-4-7), adaptive thinking è l'unica modalità di pensiero supportata. Il pensiero è disattivato a meno che tu non imposti esplicitamente thinking: {type: "adaptive"} nella tua richiesta; il manuale thinking: {type: "enabled"} viene rifiutato con un errore 400.claude-opus-4-6)claude-sonnet-4-6)thinking.type: "enabled" e budget_tokens sono deprecati su Opus 4.6 e Sonnet 4.6 e verranno rimossi in una futura versione del modello. Utilizza thinking.type: "adaptive" con il parametro effort invece. Le configurazioni budget_tokens esistenti sono ancora funzionali ma non sono più consigliate; pianifica la migrazione.
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à adattiva, il pensiero è facoltativo per il modello. Claude valuta la complessità di ogni richiesta e determina se e quanto utilizzare il pensiero esteso. Al livello di sforzo predefinito (high), Claude quasi sempre pensa. A livelli di sforzo inferiori, Claude potrebbe saltare il pensiero per problemi più semplici.
Adaptive thinking abilita anche automaticamente interleaved thinking. Ciò significa che Claude può pensare tra le chiamate di strumenti, rendendolo particolarmente efficace per i flussi di lavoro agentici.
Imposta thinking.type su "adaptive" nella tua richiesta API:
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-4-7",
max_tokens=16000,
thinking={"type": "adaptive"},
messages=[
{
"role": "user",
"content": "Explain why the sum of two even numbers is always even.",
}
],
)
for block in response.content:
if block.type == "thinking":
print(f"\nThinking: {block.thinking}")
elif block.type == "text":
print(f"\nResponse: {block.text}")Puoi combinare adaptive thinking con il parametro effort per guidare quanto Claude pensa. Il livello di sforzo agisce come guida soft per l'allocazione del pensiero di Claude:
| Livello di sforzo | Comportamento del pensiero |
|---|---|
max | Claude pensa sempre senza vincoli sulla profondità del pensiero. Disponibile su Claude Mythos Preview, Claude Opus 4.7, Claude Opus 4.6 e Claude Sonnet 4.6. |
xhigh | Claude pensa sempre profondamente con esplorazione estesa. Disponibile su Claude Opus 4.7. |
high (predefinito) | Claude pensa sempre. Fornisce ragionamento profondo su compiti complessi. |
medium | Claude utilizza un pensiero moderato. Potrebbe saltare il pensiero per query molto semplici. |
low | Claude minimizza il pensiero. Salta il pensiero per compiti semplici dove la velocità è più importante. |
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-4-7",
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)Adaptive thinking funziona perfettamente con streaming. I blocchi di pensiero vengono trasmessi tramite eventi thinking_delta proprio come la modalità di pensiero manuale:
client = anthropic.Anthropic()
with client.messages.stream(
model="claude-opus-4-7",
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)| Modalità | Configurazione | Disponibilità | Quando utilizzare |
|---|---|---|---|
| Adaptive | thinking: {type: "adaptive"} | Claude Mythos Preview (predefinito), Opus 4.7 (unica modalità), Opus 4.6, Sonnet 4.6 | Claude determina quando e quanto utilizzare il pensiero esteso. Utilizza effort per guidare. |
| Manual | thinking: {type: "enabled", budget_tokens: N} | Tutti i modelli tranne Claude Opus 4.7 (rifiutato). Deprecato su Opus 4.6 e Sonnet 4.6 (considera la modalità adattiva invece). | Quando hai bisogno di un controllo preciso sulla spesa di token di pensiero. |
| Disabled | Ometti il parametro thinking o passa {type: "disabled"} | Tutti i modelli tranne Claude Mythos Preview | Quando non hai bisogno di pensiero esteso e desideri la latenza più bassa. |
Adaptive thinking è disponibile su Claude Mythos Preview, Claude Opus 4.7, Opus 4.6 e Sonnet 4.6. Su Mythos Preview, adaptive thinking è il predefinito e si applica automaticamente quando thinking non è impostato. Su Claude Opus 4.7, adaptive thinking è l'unica modalità supportata e type: "enabled" con budget_tokens viene rifiutato. I modelli più vecchi supportano solo type: "enabled" con budget_tokens. Su Opus 4.6 e Sonnet 4.6, type: "enabled" con budget_tokens è ancora funzionale ma deprecato.
Disponibilità del pensiero interleaved per modalità:
interleaved-thinking-2025-05-14.Quando si utilizza adaptive thinking, i turni dell'assistente precedenti non devono iniziare con blocchi di pensiero. Questo è più flessibile rispetto alla modalità manuale, dove l'API applica che i turni abilitati al pensiero inizino con un blocco di pensiero.
Le richieste consecutive che utilizzano il pensiero adaptive preservano i punti di interruzione della prompt cache. Tuttavia, il passaggio tra le modalità di pensiero adaptive e enabled/disabled interrompe i punti di interruzione della cache per i messaggi. I prompt di sistema e le definizioni degli strumenti rimangono memorizzati nella cache indipendentemente dalle modifiche della modalità.
Il comportamento di attivazione del pensiero adattivo è promptable. Se Claude pensa 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 del ragionamento. Misura l'impatto sui tuoi carichi di lavoro specifici prima di distribuire la sintonizzazione basata su prompt in produzione. Considera di testare prima con livelli di effort inferiori.
Utilizza max_tokens come limite rigido sull'output totale (pensiero + testo di risposta). Il parametro effort fornisce una guida soft aggiuntiva su quanto pensiero Claude alloca. Insieme, questi ti danno un controllo efficace sui costi.
Ai livelli di sforzo high e max, Claude potrebbe pensare più estesamente e può essere più probabile che esaurisca il budget 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 sforzo.
I seguenti concetti si applicano a tutti i modelli che supportano il pensiero esteso, indipendentemente dal fatto che tu utilizzi la modalità adattiva 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. This is the default behavior on Claude 4 models when the display field on the thinking configuration is unset or set to "summarized". On Claude Opus 4.7 and Claude Mythos Preview, display defaults to "omitted" instead, so you must set display: "summarized" explicitly to receive summarized thinking.
Here are some important considerations for summarized thinking:
In rare cases where you need access to full thinking output for Claude 4 models, contact Anthropic sales.
The display field on the thinking configuration controls how thinking content is returned in API responses. It accepts two values:
"summarized": Thinking blocks contain summarized thinking text. See Summarized thinking for details. This is the default on Claude Opus 4.6, Claude Sonnet 4.6, and earlier Claude 4 models."omitted": Thinking blocks are returned with an empty thinking field. The signature field still carries the encrypted full thinking for multi-turn continuity (see Thinking encryption). This is the default on Claude Opus 4.7 and Claude Mythos Preview.Setting display: "omitted" is useful when your application doesn't surface thinking content to users. The primary benefit is faster time-to-first-text-token when streaming: The server skips streaming thinking tokens entirely and delivers only the signature, so the final text response begins streaming sooner.
Here are some important considerations for omitted thinking:
signature to reconstruct the original thinking for prompt construction (see Preserving thinking blocks). Any text you place in the thinking field of a round-tripped omitted block is ignored.display is invalid with thinking.type: "disabled" (there is nothing to display).thinking.type: "adaptive" and the model skips thinking for a simple request, no thinking block is produced regardless of display.The signature field is identical whether display is "summarized" or "omitted". Switching display values between turns in a conversation is supported.
Su Claude Opus 4.7, thinking.display è predefinito su "omitted". I blocchi di pensiero appaiono ancora nel flusso di risposta, ma il loro campo thinking è vuoto a meno che tu non esplicitamente acconsenta. Questo è un cambiamento silenzioso da Claude Opus 4.6, dove il predefinito era "summarized". Per ripristinare il testo di pensiero riassunto su Claude Opus 4.7, imposta thinking.display su "summarized" esplicitamente:
thinking = {
"type": "adaptive",
"display": "summarized",
}Per esempi di codice e comportamento di streaming con display: "omitted", vedi Controllo della visualizzazione del pensiero sulla pagina del pensiero esteso. Gli esempi lì utilizzano type: "enabled"; con adaptive thinking, utilizza:
thinking = {"type": "adaptive", "display": "omitted"}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. If you pass them back, whether the API keeps or strips them depends on the model: Opus 4.5+ and Sonnet 4.6+ keep them in context by default; earlier Opus/Sonnet models and all Haiku models strip them. See context editing to configure this.
If sending back thinking blocks, pass 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.signature values are compatible across platforms (Claude APIs, Amazon Bedrock, and Vertex AI). Values generated on one platform will be compatible with another.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:
When using display: "omitted":
thinking field is empty)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 thinking content visible in the response.
La pagina del pensiero esteso copre diversi argomenti in più dettagli con esempi di codice specifici della modalità:
tool_choice quando il pensiero è attivo.adaptive e enabled/disabled interrompe i punti di interruzione della cache per i messaggi (i prompt di sistema e le definizioni degli strumenti rimangono memorizzati nella cache).max_tokens e i limiti della finestra di contesto.Scopri di più sul pensiero esteso, inclusa la modalità manuale, l'uso dello strumento e il prompt caching.
Controlla quanto accuratamente Claude risponde con il parametro effort.
Was this page helpful?