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(azure_ai): Remove unsupported params from Azure AI Anthropic requests (#17822)
Cesar Garcia97be0da0d223
diff --git a/litellm/llms/azure_ai/anthropic/transformation.py b/litellm/llms/azure_ai/anthropic/transformation.pyindex ebefbd3bf7f..2d8d3b987c7 100644--- a/litellm/llms/azure_ai/anthropic/transformation.py+++ b/litellm/llms/azure_ai/anthropic/transformation.py@@ -98,8 +98,8 @@ class AzureAnthropicConfig(AnthropicConfig):headers: dict,) -> dict:"""- Transform request using parent AnthropicConfig, then remove extra_body if present.- Azure Anthropic doesn't support extra_body parameter.+ Transform request using parent AnthropicConfig, then remove unsupported params.+ Azure Anthropic doesn't support extra_body, max_retries, or stream_options parameters."""# Call parent transform_requestdata = super().transform_request(@@ -109,9 +109,11 @@ class AzureAnthropicConfig(AnthropicConfig):litellm_params=litellm_params,headers=headers,)-- # Remove extra_body if present (Azure Anthropic doesn't support it)++ # Remove unsupported parameters for Azure AI Anthropicdata.pop("extra_body", None)-+ data.pop("max_retries", None)+ data.pop("stream_options", None)+return datadiff --git a/tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_transformation.py b/tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_transformation.pyindex 1a20806243f..e43a899325f 100644--- a/tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_transformation.py+++ b/tests/test_litellm/llms/azure_ai/claude/test_azure_anthropic_transformation.py@@ -182,7 +182,7 @@ class TestAzureAnthropicConfig:def test_inherits_anthropic_config_methods(self):"""Test that AzureAnthropicConfig inherits methods from AnthropicConfig"""config = AzureAnthropicConfig()-+# Test that it has AnthropicConfig methodsassert hasattr(config, "get_anthropic_headers")assert hasattr(config, "is_cache_control_set")@@ -190,3 +190,48 @@ class TestAzureAnthropicConfig:assert hasattr(config, "transform_request")assert hasattr(config, "transform_response")+ def test_transform_request_removes_unsupported_params(self):+ """Test that transform_request removes max_retries, stream_options, and extra_body.++ These parameters are LiteLLM-internal and not supported by Azure AI Anthropic endpoint.+ See: https://github.com/BerriAI/litellm/issues/XXXX+ """+ config = AzureAnthropicConfig()++ messages = [{"role": "user", "content": "Hello"}]+ optional_params = {+ "max_tokens": 100,+ }+ litellm_params = {"api_key": "test-key"}+ headers = {"api-key": "test-key", "anthropic-version": "2023-06-01"}++ with patch.object(+ config.__class__.__bases__[0], # AnthropicConfig+ "transform_request",+ return_value={+ "model": "claude-sonnet-4-5",+ "messages": [{"role": "user", "content": [{"type": "text", "text": "Hello"}]}],+ "max_tokens": 100,+ "max_retries": 3, # Should be removed+ "stream_options": {"include_usage": True}, # Should be removed+ "extra_body": {"custom": "param"}, # Should be removed+ },+ ):+ result = config.transform_request(+ model="claude-sonnet-4-5",+ messages=messages,+ optional_params=optional_params,+ litellm_params=litellm_params,+ headers=headers,+ )++ # Verify unsupported params are removed+ assert "max_retries" not in result+ assert "stream_options" not in result+ assert "extra_body" not in result++ # Verify supported params are preserved+ assert result["model"] == "claude-sonnet-4-5"+ assert result["max_tokens"] == 100+ assert "messages" in result+