fix: ant beta header filters

This commit is contained in:
Ishaan Jaffer 2026-04-02 16:24:01 -07:00
parent b7ccc5b691
commit 7edf1db0c9
2 changed files with 16 additions and 4 deletions

View file

@ -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

View file

@ -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