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: guard against str response from Azure before calling model_dump() (#21634)
Darien Kindlund6bd2143a3ddd
diff --git a/litellm/llms/azure/azure.py b/litellm/llms/azure/azure.pyindex 44ee51d14ab..51b98c4af55 100644--- a/litellm/llms/azure/azure.py+++ b/litellm/llms/azure/azure.py@@ -343,6 +343,11 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):headers, response = self.make_sync_azure_openai_chat_completion_request(azure_client=azure_client, data=data, timeout=timeout)+ if isinstance(response, str):+ raise AzureOpenAIError(+ status_code=500,+ message=f"Unexpected string response from Azure: {response[:500]}",+ )stringified_response = response.model_dump()## LOGGINGlogging_obj.post_call(@@ -432,6 +437,11 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):)logging_obj.model_call_details["response_headers"] = headers+ if isinstance(response, str):+ raise AzureOpenAIError(+ status_code=500,+ message=f"Unexpected string response from Azure: {response[:500]}",+ )stringified_response = response.model_dump()logging_obj.post_call(input=data["messages"],@@ -690,7 +700,11 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):status_code=raw_response.status_code or 500,message=f"Failed to parse raw Azure embedding response: {str(json_error)}") from json_error-+ if isinstance(response, str):+ raise AzureOpenAIError(+ status_code=raw_response.status_code or 500,+ message=f"Unexpected string response from Azure: {response[:500]}",+ )stringified_response = response.model_dump()## LOGGING@@ -792,6 +806,11 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM):raw_response = azure_client.embeddings.with_raw_response.create(**data, timeout=timeout) # type: ignoreheaders = dict(raw_response.headers)response = raw_response.parse()+ if isinstance(response, str):+ raise AzureOpenAIError(+ status_code=raw_response.status_code or 500,+ message=f"Unexpected string response from Azure: {response[:500]}",+ )## LOGGINGlogging_obj.post_call(input=input,