Optimizing Token Costs with Claude Sonnet 5's Adaptive Thinking and Effort Parameter

Claude Sonnet 5, now the new standard in the 2026 frontier AI model market, is a drop-in upgrade from the previous generation (Claude Sonnet 4.6) — the API request/response shape is unchanged — but its approach to controlling thinking is completely different. The manual extended thinking config used through Claude Sonnet 4.6 (thinking: { type: "enabled", budget_tokens: N }) has been removed entirely on Sonnet 5 and now returns a 400 error. In its place, thinking depth and token spend are controlled through Adaptive Thinking, which is on by default, combined with the output_config.effort parameter.
This guide covers the thinking: { type: "adaptive" } + effort control structure in the Claude Sonnet 5 API, how the new tokenizer affects token cost calculations, and real-world patterns for optimizing cost per request in production pipelines.
Key Takeaways
- If you omit the
thinkingfield on a Claude Sonnet 5 request, it runs with Adaptive Thinking on by default (on Sonnet 4.6 and earlier, the default was off). To turn it off, you must explicitly setthinking: { type: "disabled" }.- Thinking depth is no longer controlled by a
budget_tokensinteger — it’s controlled by anoutput_config: { effort: "low" | "medium" | "high" | "xhigh" | "max" }level. The default ishigh.- Setting
temperature,top_p, ortop_kto anything other than their default values now returns a 400 error — a new constraint that didn’t exist on Sonnet 4.6.- Sonnet 5 uses a new tokenizer, so the same text now consumes roughly 30% more tokens than it did on Sonnet 4.6. This affects cost not through a higher per-token rate, but through a higher token count itself.
- Introductory pricing of $2 input / $10 output (per million tokens) applies through August 31, 2026, after which it reverts to the standard rate of $3 / $15.
Claude Sonnet 5’s Thinking Control Architecture
| Parameter / Mode | effort: "low" |
effort: "high" (default) |
effort: "xhigh" |
|---|---|---|---|
| Use case | Simple classification, chatbot responses, high-frequency low-latency requests | Complex reasoning, hard coding problems, agentic work | Long-horizon coding/agentic tasks running 30+ minutes |
| Thinking behavior | Adaptive thinking is skipped for most requests | Adaptive thinking kicks in when needed | Deeper, more frequent thinking |
| Speed/cost profile | Fastest and cheapest | The balanced point (same behavior as omitting the parameter) | Token consumption rises significantly |
If you don’t specify effort, it behaves the same as high. max is the level that delivers peak performance with no cap on token spend — reserve it for genuinely hard problems.
Calling the Claude Sonnet 5 API in Practice
Here’s a practical Node.js/TypeScript example using the Anthropic SDK that dynamically adjusts effort based on task difficulty. If you carry over the thinking.budget_tokens field you used on Sonnet 4.6 or earlier, you’ll get a 400 error — when migrating, you must switch to the pattern below.
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
type Effort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
async function runAdaptiveThinking(prompt: string, effort: Effort) {
const response = await anthropic.messages.create({
model: 'claude-sonnet-5',
max_tokens: 8192,
// The { type: 'enabled', budget_tokens: N } config used through Sonnet 4.6
// has been removed on Sonnet 5 and now returns a 400 error. Only set this
// explicitly when you want thinking off — omitting it runs Adaptive
// Thinking on by default.
thinking: { type: 'adaptive' },
output_config: { effort },
messages: [
{
role: 'user',
content: prompt,
},
],
});
for (const block of response.content) {
if (block.type === 'thinking') {
console.log('[Claude Sonnet 5 Thinking]:', block.thinking);
} else if (block.type === 'text') {
console.log('[Claude Sonnet 5 Response]:', block.text);
}
}
}
// Simple tasks use low; complex refactoring/agentic work uses xhigh
await runAdaptiveThinking('Normalize this JSON to match the schema', 'low');
await runAdaptiveThinking('Find the circular dependencies in this repo and draft a refactoring plan', 'xhigh');
For requests where you want thinking fully disabled (simple responses where latency is absolutely critical), explicitly set thinking: { type: 'disabled' }. You might be tempted to also tune temperature or top_p alongside it, but on Sonnet 5, sending a non-default sampling parameter returns a 400 error the moment you send it — so tone adjustments need to go through system prompt instructions instead.
The New Tokenizer and Production Cost Optimization Strategies
- Recount, Don’t Reuse:
Don’t reuse token counts or budgets you measured against Sonnet 4.6. Since the same text now comes out to roughly 30% more tokens under the new tokenizer, you need to re-measure every token-budget-related value — including
max_tokens— with the Token Counting API. - Dynamic Effort Routing (Task Complexity Router):
Measure the complexity of user requests or the scope of a code change and automatically map that to an
effortvalue. Route high-frequency, simple responses tolowto cut costs, and promote agentic coding or deep analysis toxhigh. - Prompt Caching:
When passing a large codebase or library type definitions as a system prompt, set
cache_control: { type: "ephemeral" }to get up to a 90% token discount on cache hits. Note that changing theeffortvalue mid-conversation invalidates the cached prefix, so it’s better for cache hit rates to keep the effort level you set at the start of a session fixed for that session. - Take advantage of the introductory pricing window: Introductory pricing of $2 input / $10 output (per million tokens) applies through August 31, 2026, after which it reverts to the standard rate of $3 / $15. It’s more cost-effective to batch large-scale migration testing or backfill work into this window.
By routing Claude Sonnet 5’s Adaptive Thinking and effort parameter to fit your production system, you can offset the higher per-token burden relative to Sonnet 4.6 while still keeping pipeline costs predictable.