Skip to content

[Feat]Add new claude 4-6 feat for v1/messages - #20733

Merged
Sameerlite merged 10 commits into
mainfrom
litellm_v1_messages_claude_4_6
Feb 9, 2026
Merged

[Feat]Add new claude 4-6 feat for v1/messages#20733
Sameerlite merged 10 commits into
mainfrom
litellm_v1_messages_claude_4_6

Conversation

@Sameerlite

@Sameerlite Sameerlite commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🆕 New Feature
🐛 Bug Fix

Changes

image

@vercel

vercel Bot commented Feb 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 9, 2026 11:51am

Request Review

@greptile-apps

greptile-apps Bot commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR extends LiteLLM’s /v1/messages support for newer Claude Opus 4.6 features across multiple providers.

Key changes:

  • Azure AI Anthropic: filters anthropic-beta to remove unsupported beta flags after building the beta header set.
  • Bedrock Invoke: replaces an inline beta whitelist with a centralized filter_and_transform_beta_headers(provider='bedrock') helper.
  • Vertex AI partner models: adds automatic anthropic-beta injection for context management (context-management-2025-06-27) and compaction (compact-2026-01-12) based on optional_params['context_management'].edits, with new unit tests.
  • Pricing JSON: removes duplicated keys for claude-opus-4-6-v1 variants, which previously would have caused silent overwrites in JSON parsers.
  • Docs: adds a /v1/messages usage section and feature matrix for Opus 4.6.

The main correctness concern is in the Vertex AI context management detection: it can add the context-management beta header even when edits are empty/invalid (e.g., {} or missing type), and the docs currently claim compaction support for Bedrock Invoke which conflicts with the provider beta filtering behavior.

Confidence Score: 4/5

  • Mostly safe to merge after addressing one behavioral bug and aligning documentation with actual provider support.
  • Core changes are small and localized, with added tests and a beneficial pricing JSON de-duplication. However, Vertex AI’s new context_management detection will incorrectly emit a beta header for empty/invalid edits, and docs currently claim Bedrock Invoke compaction support that appears inconsistent with the code’s beta filtering.
  • litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py; docs/my-website/blog/claude_opus_4_6/index.md

Important Files Changed

Filename Overview
docs/my-website/blog/claude_opus_4_6/index.md Adds a new section documenting /v1/messages usage and feature matrix; contains a misleading compaction support statement for Bedrock Invoke.
litellm/llms/azure_ai/anthropic/messages_transformation.py Filters Anthropic beta headers for Azure AI by calling the centralized header filtering helper after updating beta features.
litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py Replaces inline Bedrock beta whitelist filtering with centralized filter_and_transform_beta_headers(provider='bedrock').
litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py Adds context-management/compaction beta header injection based on optional_params['context_management'].edits; current logic can add context-management header for empty/invalid edits.
litellm/model_prices_and_context_window_backup.json Removes duplicate claude-opus-4-6-v1/regional pricing entries from backup pricing JSON (de-duplication).
model_prices_and_context_window.json Removes duplicate claude-opus-4-6-v1/global/regional entries from pricing JSON (fixes duplicate keys that were previously present).
tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py Adds tests asserting Vertex AI adds compact-2026-01-12 and/or context-management-2025-06-27 to anthropic-beta header when context_management.edits are present.

Sequence Diagram

sequenceDiagram
    participant Client
    participant LiteLLM
    participant AzureAI as Azure AI Anthropic Adapter
    participant Bedrock as Bedrock Anthropic Adapter
    participant Vertex as Vertex AI Anthropic Adapter

    Client->>LiteLLM: POST /v1/messages (Claude 4.6 params)
    alt Azure AI
        LiteLLM->>AzureAI: messages_transformation.py
        AzureAI-->>LiteLLM: provider-formatted payload
    else Bedrock
        LiteLLM->>Bedrock: anthropic_claude3_transformation.py
        Bedrock-->>LiteLLM: provider-formatted payload
    else Vertex AI Partner Model
        LiteLLM->>Vertex: pass_through/transformation.py
        Vertex-->>LiteLLM: provider-formatted payload
    end
    LiteLLM-->>Client: Anthropic-style response

Loading

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

7 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +72 to +75
context_management_param = optional_params.get("context_management")
if context_management_param is not None:
# Check edits array for compact_20260112 type
edits = context_management_param.get("edits", [])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Context management header misfire
When context_management is present but edits is empty (or contains non-dict entries), this logic sets has_other=True for every non-compact_20260112 element (including {} / missing type), which will incorrectly add the context-management-2025-06-27 beta header even though no meaningful edits were requested. Consider only treating an edit as “other” when it’s a dict with a non-empty type (and not equal to compact_20260112).

Comment on lines +460 to +463
{
"role": "user",
"content": "Explain why the sum of two even numbers is always even."
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Incorrect provider support claim
This section states: Compaction is supported on Anthropic, Bedrock Invoke Azure AI, and Vertex AI. but /v1/messages compaction is typically not supported on Bedrock Invoke (it requires anthropic_beta support for the compact feature, which Bedrock Invoke filters/whitelists). Given the code in litellm/llms/bedrock/.../anthropic_claude3_transformation.py explicitly filters provider betas, this doc line is misleading and should be corrected (and also add the missing comma: “Bedrock Invoke, Azure AI”).

@Sameerlite Sameerlite changed the title Add new claude 4-6 feat for v1/messages [Feat[Add new claude 4-6 feat for v1/messages Feb 9, 2026
@Sameerlite Sameerlite changed the title [Feat[Add new claude 4-6 feat for v1/messages [Feat]Add new claude 4-6 feat for v1/messages Feb 9, 2026
…ions/test_bedrock_chat_invoke_transformations_anthropic_claude3_transformation.py
@Sameerlite
Sameerlite merged commit e5f41ba into main Feb 9, 2026
11 of 48 checks passed
Sameerlite added a commit that referenced this pull request Feb 11, 2026
[Feat]Add new claude 4-6 feat for v1/messages
ishaan-jaff pushed a commit that referenced this pull request Feb 11, 2026
[Feat]Add new claude 4-6 feat for v1/messages
Sameerlite added a commit that referenced this pull request Feb 13, 2026
[Feat]Add new claude 4-6 feat for v1/messages
ishaan-jaff pushed a commit that referenced this pull request Feb 18, 2026
@ishaan-berri
ishaan-berri deleted the litellm_v1_messages_claude_4_6 branch March 26, 2026 22:30
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…ude_4_6

[Feat]Add new claude 4-6 feat for v1/messages
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.

1 participant