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): detect caller auth headers case-insensitively in image generation
mateoc5d50817a703
diff --git a/litellm/images/main.py b/litellm/images/main.pyindex 4c88eb52cd8..3bee6000d3f 100644--- a/litellm/images/main.py+++ b/litellm/images/main.py@@ -440,7 +440,8 @@ def image_generation(if extra_headers is not None:optional_params["extra_headers"] = extra_headers- caller_set_auth = "api-key" in headers or "Authorization" in headers+ caller_header_names = frozenset(name.lower() for name in headers)+ caller_set_auth = "api-key" in caller_header_names or "authorization" in caller_header_namesauth_headers = (headersif caller_set_authdiff --git a/tests/test_litellm/llms/azure_ai/test_azure_ai_entra_auth.py b/tests/test_litellm/llms/azure_ai/test_azure_ai_entra_auth.pyindex 8ac37feee4b..1145439a7b4 100644--- a/tests/test_litellm/llms/azure_ai/test_azure_ai_entra_auth.py+++ b/tests/test_litellm/llms/azure_ai/test_azure_ai_entra_auth.py@@ -121,7 +121,8 @@ def test_image_generation_authenticates_with_entra_token():assert "api-key" not in headers-def test_image_generation_keeps_caller_supplied_authorization_header():[email protected]("header_name", ["Authorization", "authorization", "api-key", "API-KEY"])+def test_image_generation_keeps_caller_supplied_auth_header(header_name):with patch.object(litellm.images.main.azure_chat_completions, "image_generation") as mock_image_generation:mock_image_generation.return_value = litellm.ImageResponse()@@ -129,12 +130,12 @@ def test_image_generation_keeps_caller_supplied_authorization_header():model="azure_ai/FLUX-1.1-pro",prompt="a red circle",api_base="https://my-resource.services.ai.azure.com",- headers={"Authorization": "Bearer caller-token"},+ headers={header_name: "caller-credential"},)headers = mock_image_generation.call_args.kwargs["headers"]- assert headers["Authorization"] == "Bearer caller-token"- assert "api-key" not in headers+ assert headers[header_name] == "caller-credential"+ assert len(headers) == 2def test_image_generation_still_uses_api_key_header():