BerriAI/litellm · error · AzureOpenAIError
Failed to parse raw Azure embedding response
Error message
Failed to parse raw Azure embedding response: {json_error} What it means
Error "Failed to parse raw Azure embedding response: {json_error}" thrown in BerriAI/litellm.
Solutions
- Check the raw embedding response; it is not valid JSON. Verify the deployment and endpoint.
When it happens
Trigger: Thrown at litellm/llms/azure/azure.py:698 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/7090bb30ac22824a.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/azure/azure.py:698
raw_response: Final = await openai_aclient.embeddings.with_raw_response.create(**data, timeout=timeout)
headers: Final = dict(raw_response.headers)
# Convert json.JSONDecodeError to AzureOpenAIError for two critical reasons:
#
# 1. ROUTER BEHAVIOR: The router relies on exception.status_code to determine cooldown logic:
# - JSONDecodeError has no status_code → router skips cooldown evaluation
# - AzureOpenAIError has status_code → router properly evaluates for cooldown
#
# 2. CONNECTION CLEANUP: When response.parse() throws JSONDecodeError, the response
# body may not be fully consumed, preventing httpx from properly returning the
# connection to the pool. By catching the exception and accessing raw_response.status_code,
# we trigger httpx's internal cleanup logic. Without this:
# - parse() fails → JSONDecodeError bubbles up → httpx never knows response was acknowledged → connection leak
# This completely eliminates "Unclosed connection" warnings during high load.
try:
response = raw_response.parse()
except json.JSONDecodeError as json_error:
raise AzureOpenAIError(
status_code=raw_response.status_code or 500,
message=f"Failed to parse raw Azure embedding response: {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: Final = response.model_dump()
## LOGGING
logging_obj.post_call(
input=input,
api_key=api_key,
additional_args={"complete_input_dict": data},
original_response=stringified_response,
)
embedding_response: Final = convert_to_model_response_object(View on GitHub (pinned to 77b7c6c40c)