BerriAI/litellm · error · AzureOpenAIError

Unexpected string response from Azure

Error message

Unexpected string response from Azure: {response[:500]}

What it means

Error "Unexpected string response from Azure: {response[:500]}" thrown in BerriAI/litellm.

Solutions

  1. Inspect the string response shown in the error; Azure returned a non-JSON body (often an auth or endpoint error page).
  2. Verify api_base, api_version, and deployment name.

When it happens

Trigger: Thrown at litellm/llms/azure/azure.py:350 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/79b58168abe92e68. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/azure/azure.py:350

                    api_version=api_version,
                    api_base=api_base,
                    api_key=api_key,
                    model=model,
                    client=client,
                    _is_async=False,
                    litellm_params=litellm_params,
                )
                if not isinstance(azure_client, (AzureOpenAI, OpenAI)):
                    raise AzureOpenAIError(
                        status_code=500,
                        message="azure_client is not an instance of AzureOpenAI or OpenAI",
                    )

                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: Final = response.model_dump()
                ## LOGGING
                logging_obj.post_call(
                    input=messages,
                    api_key=api_key,
                    original_response=stringified_response,
                    additional_args={
                        "headers": headers,
                        "api_version": api_version,
                        "api_base": api_base,
                    },
                )
                return convert_to_model_response_object(
                    response_object=stringified_response,
                    model_response_object=model_response,

View on GitHub (pinned to 77b7c6c40c)