The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Fix:Support both JSON array format and comma-separated values from user headers
Sameer Kankute1bf33c4e41f8
diff --git a/litellm/llms/bedrock/common_utils.py b/litellm/llms/bedrock/common_utils.pyindex 89b42f5e947..65d237bdbdf 100644--- a/litellm/llms/bedrock/common_utils.py+++ b/litellm/llms/bedrock/common_utils.py@@ -797,7 +797,7 @@ class BedrockEventStreamDecoderBase:def get_anthropic_beta_from_headers(headers: dict) -> List[str]:"""Extract anthropic-beta header values and convert them to a list.- Supports comma-separated values from user headers.+ Supports both JSON array format and comma-separated values from user headers.Used by both converse and invoke transformations for consistent handlingof anthropic-beta headers that should be passed to AWS Bedrock.@@ -812,8 +812,25 @@ def get_anthropic_beta_from_headers(headers: dict) -> List[str]:if not anthropic_beta_header:return []- # Split comma-separated values and strip whitespace- return [beta.strip() for beta in anthropic_beta_header.split(",")]+ # If it's already a list, return it+ if isinstance(anthropic_beta_header, list):+ return anthropic_beta_header++ # Try to parse as JSON array first (e.g., '["interleaved-thinking-2025-05-14", "claude-code-20250219"]')+ if isinstance(anthropic_beta_header, str):+ anthropic_beta_header = anthropic_beta_header.strip()+ if anthropic_beta_header.startswith("[") and anthropic_beta_header.endswith("]"):+ try:+ parsed = json.loads(anthropic_beta_header)+ if isinstance(parsed, list):+ return [str(beta).strip() for beta in parsed]+ except json.JSONDecodeError:+ pass # Fall through to comma-separated parsing++ # Fall back to comma-separated values+ return [beta.strip() for beta in anthropic_beta_header.split(",")]++ return []class CommonBatchFilesUtils: