On March 30, 2026, Anthropic announced that the 1M token context window beta for Claude Sonnet 4.5 and Claude Sonnet 4 will be retired on April 30, 2026. If your application currently uses the context-1m-2025-08-07 beta header to handle long-context requests, you need to act before that date to avoid unexpected errors in production.
What's Being Retired
When Anthropic introduced long-context support for Claude Sonnet 4 and Sonnet 4.5, it was released as a beta feature that required a special header in every API request:
anthropic-beta: context-1m-2025-08-07
This header signaled to the API that your request might exceed the standard 200K token context window, allowing inputs up to 1 million tokens.
After April 30, 2026, this changes. The beta header will be silently ignored, and any request exceeding 200K tokens sent to Claude Sonnet 4.5 or Sonnet 4 will return a context window exceeded error — even if the header is present.
Which Models Are Affected
Models affected (action required):
claude-sonnet-4-5-20250929(Claude Sonnet 4.5)claude-sonnet-4-20250522(Claude Sonnet 4)
Models not affected (1M tokens supported natively):
claude-sonnet-4-6-20260217(Claude Sonnet 4.6) — no beta header neededclaude-opus-4-6-20260205(Claude Opus 4.6) — no beta header needed
Claude Sonnet 4.6 and Claude Opus 4.6 both support 1M token context windows as a standard feature. There's no beta header to include, no special opt-in — it just works. Requests exceeding 200K tokens are automatically handled with long-context pricing applied.
Before and After: Code Migration Examples
Python SDK
import anthropic
client = anthropic.Anthropic()
# ❌ Old approach — will stop working after April 30, 2026
response = client.messages.create(
model="claude-sonnet-4-5-20250929", # Sonnet 4.5
max_tokens=8192,
extra_headers={
"anthropic-beta": "context-1m-2025-08-07" # This header will be ignored
},
messages=[
{"role": "user", "content": very_long_document} # 200K+ tokens
]
)
# ✅ New approach — Claude Sonnet 4.6 with native 1M context
response = client.messages.create(
model="claude-sonnet-4-6-20260217", # Upgrade to Sonnet 4.6
max_tokens=8192,
# No extra_headers needed — 1M context is built-in
messages=[
{"role": "user", "content": very_long_document} # Still supports up to 1M tokens
]
)
# Example response output:
# response.model → "claude-sonnet-4-6-20260217"
# response.usage.input_tokens → actual token count of your inputTypeScript / Node.js SDK
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
// ✅ Migrated TypeScript code
const response = await client.messages.create({
model: "claude-sonnet-4-6-20260217", // Changed from Sonnet 4.5
max_tokens: 8192,
// Removed: headers: { "anthropic-beta": "context-1m-2025-08-07" }
messages: [
{
role: "user",
content: veryLongDocument, // Up to 1M tokens supported natively
},
],
});
const text = response.content[0].type === "text" ? response.content[0].text : "";
console.log(text);Three Steps to Complete Your Migration
Step 1: Find all affected usages in your codebase
Start by searching your project for the beta header and older model names:
# Search for the deprecated beta header
grep -r "context-1m-2025-08-07" ./
# Search for the affected model IDs
grep -r "claude-sonnet-4-5\|claude-sonnet-4-20250522" ./src/This gives you a complete list of files that need updating.
Step 2: Update the model name and remove the beta header
For each location you found, make two changes:
- Replace
claude-sonnet-4-5-20250929withclaude-sonnet-4-6-20260217 - Remove any
anthropic-beta: context-1m-2025-08-07header configuration
If you store model names as environment variables or in a config file (which is a good practice), you only need to update it in one place:
# Example: updating an environment variable
# Before
ANTHROPIC_MODEL=claude-sonnet-4-5-20250929
ANTHROPIC_BETA_HEADER=context-1m-2025-08-07
# After
ANTHROPIC_MODEL=claude-sonnet-4-6-20260217
# ANTHROPIC_BETA_HEADER is no longer needed — remove itStep 3: Verify in a staging environment
Before pushing to production, run your most important use cases — particularly any that involve long documents or conversations exceeding 200K tokens — and confirm:
- Responses are returned successfully
- The response quality meets your expectations
- Token counts and costs align with your estimates
Benefits of Moving to Claude Sonnet 4.6
This isn't just a maintenance migration. Claude Sonnet 4.6 brings real improvements over Sonnet 4.5:
Performance gains:
- Improved performance on agentic search tasks compared to Sonnet 4.5
- Better token efficiency — many tasks complete with fewer tokens consumed
- Native support for Extended Thinking, useful for complex multi-step reasoning
Operational simplicity:
- No beta header management across different environments
- Reduced risk of configuration drift between dev and production
- Supported as a current-generation model with a longer active lifecycle
For a deep dive into maximizing Claude Sonnet 4.6's capabilities — including 1M context strategies and Extended Thinking patterns — check out Claude Sonnet 4.6 Complete Mastery Guide.
Pricing Considerations
The long-context pricing model remains the same: standard per-token rates apply up to 200K input tokens, and a higher per-token rate kicks in for input tokens beyond that threshold. Sonnet 4.6's long-context pricing is comparable to Sonnet 4.5, so your costs shouldn't change significantly.
One area where you might see savings: Sonnet 4.6's improved token efficiency can mean shorter, equally capable responses — which directly reduces both token usage and cost.
Migration Checklist
Use this checklist to make sure your migration is complete before April 30:
- Search codebase for
context-1m-2025-08-07and note every location - Search codebase for
claude-sonnet-4-5-20250929andclaude-sonnet-4-20250522 - Update model names to
claude-sonnet-4-6-20260217(orclaude-opus-4-6-20260205where appropriate) - Remove all instances of the
context-1m-2025-08-07beta header - Update environment variables and config files if model names are stored there
- Test long-context requests (200K+ tokens) in a staging environment
- Deploy changes to production before April 30, 2026
Looking back
The 1M token context window beta for Claude Sonnet 4.5 and Sonnet 4 ends on April 30, 2026. Migrating is straightforward: update your model name to claude-sonnet-4-6-20260217 and remove the context-1m-2025-08-07 beta header. Claude Sonnet 4.6 supports 1M tokens natively with no configuration needed, and brings meaningful improvements in efficiency and agentic task performance.
For practical context window management patterns — including strategies for working efficiently within token limits and handling very long documents — see Claude 200K Context Window Production Mastery.