feat: add 1M context support for Claude Sonnet 4.5 via env vars #6660
+17
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for enabling 1M token context windows for Claude Sonnet 4.5 through environment variables for both Anthropic direct and Vertex AI Anthropic providers.
Note: Currently only Claude Sonnet 4.5 supports 1M token context windows. All other Claude models (Opus 4, Haiku 4.5, etc.) remain at 200K tokens according to models.dev.
Changes
Anthropic Direct: Add
ANTHROPIC_1M_CONTEXT=trueenv var to enable 1M context for Sonnet 4.5context-1m-2025-08-07beta when enabledVertex AI Anthropic: Add
VERTEX_ANTHROPIC_1M_CONTEXT=trueenv var to enable 1M context for Sonnet 4.5anthropic-beta: context-1m-2025-08-07header when enabledModel Detection: Regex pattern specifically matches Claude Sonnet 4.5 variants only
claude-sonnet-4.5,claude-sonnet-4-5,claude-sonnet-4.5-20250929Testing
Usage
```bash
For Anthropic direct (Sonnet 4.5 only)
export ANTHROPIC_1M_CONTEXT=true
For Vertex AI Anthropic (Sonnet 4.5 only)
export VERTEX_ANTHROPIC_1M_CONTEXT=true
```