Skip to content

fix: enable context-1m-2025-08-07 beta header for vertex_ai provider#21867

Merged
1 commit merged intoBerriAI:mainfrom
stakeswky:fix/vertex-ai-context-1m-beta-header
Feb 22, 2026
Merged

fix: enable context-1m-2025-08-07 beta header for vertex_ai provider#21867
1 commit merged intoBerriAI:mainfrom
stakeswky:fix/vertex-ai-context-1m-beta-header

Conversation

@stakeswky
Copy link
Copy Markdown
Contributor

Description

Fixes #21861

Root Cause

In litellm/anthropic_beta_headers_config.json, the context-1m-2025-08-07 beta header was set to null for the vertex_ai provider:

"vertex_ai": {
  "context-1m-2025-08-07": null,  // ← bug: should be "context-1m-2025-08-07"
  ...
}

This caused filter_and_transform_beta_headers to filter out the header when users set extra_headers: {anthropic-beta: context-1m-2025-08-07} in their Vertex AI config, resulting in a BadRequestError (prompt too long) instead of enabling 1M context.

Fix

Set context-1m-2025-08-07 to "context-1m-2025-08-07" for vertex_ai, consistent with:

  • bedrock_converse: already "context-1m-2025-08-07"
  • azure_ai: already "context-1m-2025-08-07"
  • Anthropic's documentation: Vertex AI supports the same options as the Messages API

Testing

The existing test suite in tests/test_litellm/test_anthropic_beta_headers_filtering.py is data-driven and reads directly from the config file, so it will automatically validate this fix.

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
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 22, 2026 2:42am

Request Review

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 22, 2026

Greptile Summary

Fixes context-1m-2025-08-07 beta header for the vertex_ai provider by changing its value from null (unsupported) to "context-1m-2025-08-07" (supported) in the beta headers config, enabling 1M context window support on Vertex AI.

  • Changed "context-1m-2025-08-07": null to "context-1m-2025-08-07": "context-1m-2025-08-07" in the vertex_ai section of litellm/anthropic_beta_headers_config.json
  • This aligns vertex_ai with anthropic, azure_ai, bedrock_converse, bedrock, and databricks providers, all of which already had this header enabled
  • Added a trailing newline at end of file (standard convention)
  • The existing data-driven test suite in tests/test_litellm/test_anthropic_beta_headers_filtering.py reads from this config and will automatically validate the fix

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, well-scoped config-only fix with no risk of regressions.
  • The change is a single-value fix in a JSON config file (null → string), consistent with all other providers. The filtering logic in anthropic_beta_headers_manager.py is well-tested with data-driven tests that automatically cover this fix. No code logic changes are involved.
  • No files require special attention.

Important Files Changed

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"]
Loading

Last reviewed commit: 8f77c05

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@ghost ghost merged commit 41837ef into BerriAI:main Feb 22, 2026
30 of 31 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Missing context-1m-2025-08-07 config for vertex_ai

2 participants