fix: enable context-1m-2025-08-07 beta header for vertex_ai provider#21867
Merged
1 commit merged intoBerriAI:mainfrom Feb 22, 2026
Merged
Conversation
The context-1m-2025-08-07 beta header was incorrectly set to null for vertex_ai in anthropic_beta_headers_config.json, causing the header to be filtered out when users set extra_headers with anthropic-beta: context-1m-2025-08-07 for Vertex AI requests. Vertex AI supports the same beta headers as the Anthropic Messages API, and other providers (bedrock_converse, azure_ai) already have this header enabled. This fix aligns vertex_ai with the correct behavior. Fixes BerriAI#21861
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
Contributor
Greptile SummaryFixes
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/anthropic_beta_headers_config.json | Changed context-1m-2025-08-07 value from null to "context-1m-2025-08-07" for vertex_ai provider, plus trailing newline fix. No issues found. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["User sets extra_headers:\n{anthropic-beta: context-1m-2025-08-07}"] --> B["filter_and_transform_beta_headers()"]
B --> C{"Lookup header in\nvertex_ai config"}
C -->|"Before fix: null"| D["Header filtered out ❌\nBadRequestError: prompt too long"]
C -->|"After fix: 'context-1m-2025-08-07'"| E["Header forwarded ✅\n1M context enabled"]
Last reviewed commit: 8f77c05
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #21861
Root Cause
In
litellm/anthropic_beta_headers_config.json, thecontext-1m-2025-08-07beta header was set tonullfor thevertex_aiprovider:This caused
filter_and_transform_beta_headersto filter out the header when users setextra_headers: {anthropic-beta: context-1m-2025-08-07}in their Vertex AI config, resulting in aBadRequestError(prompt too long) instead of enabling 1M context.Fix
Set
context-1m-2025-08-07to"context-1m-2025-08-07"forvertex_ai, consistent with:bedrock_converse: already"context-1m-2025-08-07"azure_ai: already"context-1m-2025-08-07"Testing
The existing test suite in
tests/test_litellm/test_anthropic_beta_headers_filtering.pyis data-driven and reads directly from the config file, so it will automatically validate this fix.