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: drop a blank anthropic-beta header before it reaches the provider
mateo-berri0f0c0fe499fc
diff --git a/litellm/anthropic_beta_headers_manager.py b/litellm/anthropic_beta_headers_manager.pyindex abce47c191e..7e7099a53b0 100644--- a/litellm/anthropic_beta_headers_manager.py+++ b/litellm/anthropic_beta_headers_manager.py@@ -334,7 +334,7 @@ def update_headers_with_filtered_beta(Updated headers dict"""existing_beta: Final = headers.get("anthropic-beta")- if not existing_beta:+ if existing_beta is None:return headers# Parse existing beta headersdiff --git a/tests/test_litellm/test_anthropic_beta_headers_filtering.py b/tests/test_litellm/test_anthropic_beta_headers_filtering.pyindex 3c967283abf..d404edb1281 100644--- a/tests/test_litellm/test_anthropic_beta_headers_filtering.py+++ b/tests/test_litellm/test_anthropic_beta_headers_filtering.py@@ -18,6 +18,7 @@ import pytestimport litellmfrom litellm.anthropic_beta_headers_manager import (filter_and_transform_beta_headers,+ update_headers_with_filtered_beta,update_request_with_filtered_beta,)@@ -511,3 +512,20 @@ class TestAnthropicBetaHeadersFiltering:assert ("unknown-header-123" not in filtered), f"Unknown header should not be in result for {provider}"++ @pytest.mark.parametrize("provider", ["anthropic", "bedrock", "bedrock_mantle", "vertex_ai"])+ def test_blank_anthropic_beta_header_is_removed(self, provider):+ headers = {"anthropic-beta": "", "anthropic-version": "2023-06-01"}++ assert update_headers_with_filtered_beta(headers, provider) == {"anthropic-version": "2023-06-01"}++ @pytest.mark.parametrize("provider", ["anthropic", "bedrock", "bedrock_mantle", "vertex_ai"])+ def test_whitespace_only_anthropic_beta_header_is_removed(self, provider):+ headers = {"anthropic-beta": " , ", "anthropic-version": "2023-06-01"}++ assert update_headers_with_filtered_beta(headers, provider) == {"anthropic-version": "2023-06-01"}++ def test_absent_anthropic_beta_header_is_left_alone(self):+ headers = {"anthropic-version": "2023-06-01"}++ assert update_headers_with_filtered_beta(headers, "bedrock_mantle") == {"anthropic-version": "2023-06-01"}