fix _should_use_api_key_header

This commit is contained in:
Ishaan Jaff 2025-02-26 16:28:19 -08:00
parent 680f815991
commit d6ea047bd1

View file

@ -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,