From 7edf1db0c98932651c389c0df12eee943ed26dce Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 2 Apr 2026 16:24:01 -0700 Subject: [PATCH] fix: ant beta header filters --- litellm/llms/bedrock/chat/converse_transformation.py | 10 ++++++++-- .../anthropic_claude3_transformation.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index 5cfb00d69b6..67b32cc521b 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -12,6 +12,7 @@ import httpx import litellm from litellm._logging import verbose_logger +from litellm.anthropic_beta_headers_manager import filter_and_transform_beta_headers from litellm.constants import ( BEDROCK_MIN_THINKING_BUDGET_TOKENS, RESPONSE_FORMAT_TOOL_NAME, @@ -1362,11 +1363,16 @@ class AmazonConverseConfig(BaseConfig): # Append pre-formatted tools (systemTool etc.) after transformation bedrock_tools.extend(pre_formatted_tools) - # Set anthropic_beta in additional_request_params if we have any beta features + # Filter and set anthropic_beta in additional_request_params if we have any beta features # ONLY apply to Anthropic/Claude models - other models (e.g., Qwen, Llama) don't support this field base_model = BedrockModelInfo.get_base_model(model) if anthropic_beta_list and base_model.startswith("anthropic"): - additional_request_params["anthropic_beta"] = anthropic_beta_list + filtered_beta_list = filter_and_transform_beta_headers( + beta_headers=anthropic_beta_list, + provider="bedrock_converse", + ) + if filtered_beta_list: + additional_request_params["anthropic_beta"] = filtered_beta_list return bedrock_tools, anthropic_beta_list diff --git a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py index 7936b6ea644..17f673335de 100644 --- a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py +++ b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py @@ -2,6 +2,7 @@ from typing import TYPE_CHECKING, Any, List, Optional import httpx +from litellm.anthropic_beta_headers_manager import filter_and_transform_beta_headers from litellm.llms.anthropic.chat.transformation import AnthropicConfig from litellm.llms.bedrock.chat.invoke_transformations.base_invoke_transformation import ( AmazonInvokeConfig, @@ -144,8 +145,13 @@ class AmazonAnthropicClaudeConfig(AmazonInvokeConfig, AnthropicConfig): # Filter out beta headers that Bedrock Invoke doesn't support # Uses centralized configuration from anthropic_beta_headers_config.json - beta_list = list(beta_set) - _anthropic_request["anthropic_beta"] = beta_list + filtered_beta_list = filter_and_transform_beta_headers( + beta_headers=list(beta_set), + provider="bedrock", + ) + + if filtered_beta_list: + _anthropic_request["anthropic_beta"] = filtered_beta_list return _anthropic_request