How to Switch to Claude Sonnet 5: 3 Breaking Changes and a Hidden 30% Token Cost
Read time: ~7 minutes. What you’ll learn: the exact model ID, the one-line swap, the three API behavior changes that return
400errors if you ignore them (adaptive thinking on by default, sampling parameters rejected, manual extended thinking removed) with before/after code, the new tokenizer’s ~30% token increase and how to re-budget for it, pricing (including the introductory window), where Sonnet 5 is available, and when to reach for Opus 4.8 instead.Sourcing note: every technical claim, code snippet, price, and behavior change below is from Anthropic’s official What’s new in Claude Sonnet 5 doc and the Claude Sonnet 5 announcement. No benchmark numbers are invented; where a figure is Anthropic’s own, it’s cited. Links at the bottom.
Anthropic ships Claude Sonnet 5 as a “drop-in replacement for Claude Sonnet 4.6.” That’s mostly true — the request and response shapes are unchanged — but “drop-in” quietly hides three behavior changes that will throw 400 errors on code that worked yesterday, plus a tokenizer swap that changes what every request costs. If you run Sonnet in production, this is a 15-minute migration you want to do deliberately, not discover through a pager alert. Here’s the whole thing.
1. The one-line change (and why you can’t stop there)
The model itself:
| Model | API model ID | Context | Max output |
|---|---|---|---|
| Claude Sonnet 5 | claude-sonnet-5 | 1M tokens (default and max) | 128K tokens |
The migration starts as a single line:
model = "claude-sonnet-4-6" # Before
model = "claude-sonnet-5" # After
If your code sets no sampling parameters, no manual thinking budget, and doesn’t prefill assistant messages, that might genuinely be all you need. But most production code does at least one of those — so walk the three breaking changes below before you ship.
One spec note up front: Sonnet 5 supports the 1M-token context window by default (it’s both the default and the maximum — there is no smaller-context variant), and 128K max output tokens. It carries the same tools and platform features as Sonnet 4.6, with one exception: Priority Tier is not available on Sonnet 5.
2. Breaking change #1 — Adaptive thinking is on by default
On Sonnet 4.6, a request with no thinking field ran without thinking. On Sonnet 5, that same request runs with adaptive thinking — the model decides how much to think per request.
This won’t error, but it changes two things you may be relying on:
- Latency and output composition shift. Requests that used to return fast, thinking-free completions now may include internal thinking.
max_tokensis a hard cap on thinking plus response text. If you tunedmax_tokenstightly on 4.6 for no-thinking workloads, Sonnet 5 can now spend part of that budget on thinking and truncate your actual answer.
To keep the old behavior, turn thinking off explicitly:
# Restore Sonnet 4.6-style no-thinking behavior
thinking = {"type": "disabled"}
Action: if you had latency-sensitive or tightly-budgeted no-thinking calls, either pass thinking: {type: "disabled"} or raise max_tokens to leave room for thinking.
3. Breaking change #2 — Sampling parameters are rejected
This is the one that bites hardest. On Sonnet 5:
Setting
temperature,top_p, ortop_kto a non-default value returns a 400 error.
If your client hard-codes temperature=0 for deterministic output, or temperature=0.7 for a chat persona, those requests now fail outright. Remove the parameters — omitting them (or leaving them at default) is accepted:
# Before (Sonnet 4.6) — now returns 400 on Sonnet 5
resp = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
temperature=0.2, # ❌ non-default → 400
top_p=0.9, # ❌ non-default → 400
messages=[...],
)
# After — remove sampling params
resp = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[...],
)
Anthropic’s guidance is to use system-prompt instructions to steer behavior instead of sampling knobs. If you previously leaned on low temperature for consistency, add an explicit instruction:
system = (
"Be precise and deterministic. Prefer the single most likely answer; "
"do not add creative variation or hedging."
)
This isn’t Sonnet-5-specific weirdness — the same constraint landed earlier on Claude Opus 4.7 and 4.8. Sonnet 5 is just the first Sonnet-class model to inherit it. (See our Opus 4.8 switch guide — the same removal applied there.)
4. Breaking change #3 — Manual extended thinking is removed
Manual extended thinking — passing an explicit token budget — was deprecated on Sonnet 4.6. On Sonnet 5 it is removed and returns a 400 error (the same as on Opus 4.7 and 4.8). Use adaptive thinking instead:
# Not supported on Claude Sonnet 5 (returns 400)
thinking = {"type": "enabled", "budget_tokens": 32000}
# Use this instead
thinking = {"type": "adaptive"}
If you need to bias how hard the model thinks, use the effort parameter with adaptive thinking rather than a fixed budget_tokens.
Action: grep your codebase for budget_tokens and "type": "enabled" and replace with adaptive thinking (+ effort if you need the control).
5. The hidden cost: a new tokenizer that adds ~30% tokens
This is the change most teams miss because it throws no error. Sonnet 5 uses a new tokenizer, and per Anthropic:
The same input text produces approximately 30% more tokens than on Claude Sonnet 4.6.
Crucially, this is not an API change — request/response/streaming shapes are identical and no code changes are required. But it silently affects everything you measure or budget in tokens:
- Token counts go up.
usagefields and token-counting results for the same text are higher. Don’t reuse counts measured against 4.6 — recount against Sonnet 5. - Context holds less text. The window is still 1M tokens, but each token covers less text on average, so the same 1M window fits less of your content than it did on 4.6.
max_tokenscan truncate. An output limit tuned for 4.6 may cut off equivalent output on Sonnet 5. Revisit limits sized close to your expected output length.- Per-request cost shifts. Per-token pricing is unchanged, but since the same text is now more tokens, an equivalent request can cost more.
Worked example. Say a 4.6 request was ~10,000 input tokens at the standard $3/M input rate = $0.030. The same text on Sonnet 5 is ~13,000 tokens → $0.039 — a ~30% jump on that request, with no price change and no code change. Multiply across your traffic before you assume cost parity.
Action: before flipping traffic, run your real prompts through token counting against claude-sonnet-5, then re-check max_tokens and your cost projections.
6. Pricing (and the introductory window)
Per-token pricing is unchanged from Sonnet 4.6:
| Rate | Input (per 1M) | Output (per 1M) |
|---|---|---|
| Introductory (through Aug 31, 2026) | $2 | $10 |
| Standard (from Sep 1, 2026) | $3 | $15 |
Two cost levers stack on top, per Anthropic: up to 90% savings with prompt caching and 50% savings with batch processing — see the pricing docs for exact rates. Remember the tokenizer point from §5: even at the introductory rate, an equivalent request is more tokens than on 4.6, so model both the rate and the token count when you budget.
7. One more inherited constraint: no assistant prefilling
Not new, but worth confirming during migration: prefilling the assistant message returns a 400 error on Sonnet 5, exactly as on Sonnet 4.6. If you relied on prefill to force a response format, switch to structured outputs, system-prompt instructions, or output_config.format.
Also new at the Sonnet tier: real-time cybersecurity safeguards. Requests touching prohibited or high-risk cybersecurity topics may be refused — and a refusal comes back as a successful HTTP 200 with stop_reason: "refusal", not an error. If you have code that only inspects HTTP status, add a check for stop_reason == "refusal" so refusals don’t look like empty successes.
8. Where you can run it
At launch, Sonnet 5 is available on:
- Claude API — all customers.
- AWS — Amazon Bedrock and Claude Platform on AWS. Not on the legacy Bedrock
InvokeModel/Conversepath. - Google Cloud — via Vertex AI.
- Microsoft Foundry — in preview.
Zero-data-retention is supported for orgs with ZDR agreements. It’s also live in Claude Code and the Claude apps across all plans, so your editor picks it up too.
9. When to use Sonnet 5 vs Opus 4.8
Anthropic positions Sonnet 5 as “close to Opus 4.8 performance at lower prices,” with the largest gains over Sonnet 4.6 in coding and agentic tasks, plus lower hallucination and sycophancy rates.
Practical rule of thumb:
- Reach for Sonnet 5 for real-time agents, high-volume pipelines, and most coding/agentic work where you want near-Opus quality without Opus pricing. At the introductory $2/$10, it’s especially easy to justify.
- Stay on / move to Opus 4.8 when you’re at the hardest end of agentic capability and the quality gap — narrower than before, but still there — actually matters to your task. See our Opus 4.8 deep-dive and switch guide.
For the full benchmark tables, Anthropic publishes results on its Transparency Hub.
10. Migration checklist
- Swap the model ID →
claude-sonnet-5. - Remove
temperature/top_p/top_k(non-default values now 400). Move that intent into the system prompt. - Replace manual
budget_tokensthinking with{"type": "adaptive"}(+ effort if needed). - Decide on thinking: if you need old no-thinking behavior, pass
{"type": "disabled"}; otherwise revisitmax_tokensso thinking doesn’t crowd out your answer. - Recount tokens under the new tokenizer; re-check
max_tokensand cost projections (~30% more tokens for the same text). - Confirm no assistant prefilling; handle
stop_reason: "refusal"as a valid 200 response. - Re-budget against the introductory $2/$10 (through Aug 31, 2026), knowing standard $3/$15 follows.
The takeaway
Sonnet 5 (claude-sonnet-5) really is close to a drop-in upgrade — but “drop-in” means after you handle three 400-error behavior changes (sampling parameters rejected, manual extended thinking removed, adaptive thinking on by default) and re-budget for a tokenizer that adds ~30% tokens to the same text. Do the model-ID swap, strip the sampling params, migrate thinking to adaptive, recount your tokens, and you get near-Opus-4.8 quality at Sonnet prices — with introductory $2/$10 rates through August 31, 2026 sweetening the move.
For related migrations, see switching to Opus 4.8, the Opus 4.8 deep-dive, and switching to Fable 5.
Sources
- What’s new in Claude Sonnet 5 — Claude Platform Docs — model id
claude-sonnet-5, 1M context / 128K output, the three behavior changes (adaptive thinking default, sampling params 400, manual extended thinking removed) with code, new tokenizer ~30% more tokens, no assistant prefilling, cybersecurity refusal as 200 +stop_reason: "refusal", availability, migration guide, pricing $3/$15 (intro $2/$10 through Aug 31 2026) - Claude Sonnet 5 — Anthropic announcement — introductory pricing, positioning close to Opus 4.8 at lower price, gains over Sonnet 4.6, prompt caching / batch savings
- Anthropic Transparency Hub — official benchmark results
- Adaptive thinking — Claude Platform Docs and effort parameter — the recommended replacement for manual
budget_tokens - Token counting — Claude Platform Docs — recount prompts under the new tokenizer before migrating
- Verified against Anthropic’s official docs on July 1, 2026. Pricing windows and availability can change — confirm on the pricing and model docs before relying on them.