From d6ea047bd10a5d0c4b00b60fbabbee893c06db03 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 26 Feb 2025 16:28:19 -0800 Subject: [PATCH] fix _should_use_api_key_header --- litellm/llms/azure_ai/chat/transformation.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/litellm/llms/azure_ai/chat/transformation.py b/litellm/llms/azure_ai/chat/transformation.py index afedc950019..3587fa5d3f9 100644 --- a/litellm/llms/azure_ai/chat/transformation.py +++ b/litellm/llms/azure_ai/chat/transformation.py @@ -28,13 +28,21 @@ class AzureAIStudioConfig(OpenAIConfig): api_key: Optional[str] = None, api_base: Optional[str] = None, ) -> dict: - if api_base and "services.ai.azure.com" in api_base: + if api_base and self._should_use_api_key_header(api_base): headers["api-key"] = api_key else: headers["Authorization"] = f"Bearer {api_key}" return headers + def _should_use_api_key_header(self, api_base: str) -> bool: + """ + Returns True if the request should use `api-key` header for authentication. + """ + if "services.ai.azure.com" in api_base or "openai.azure.com" in api_base: + return True + return False + def get_complete_url( self, api_base: str,