BerriAI/litellm · error · BadRequestError

AzureException

Error message

AzureException - {message}

What it means

Azure-specific catch-all for status-code 400 errors not matched by earlier string checks: re-raised as litellm BadRequestError with the Azure message preserved, meaning the request itself was rejected by the service.

Solutions

  1. Inspect the Azure error message and fix the request or configuration accordingly.
  2. Enable verbose logging for the full Azure response.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1979 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/ff3427921d6c10bf. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1979

        )
    elif "The api_key client option must be set either by passing api_key to the client or by setting" in error_str:
        raise AuthenticationError(
            message=f"{exception_provider} AuthenticationError - {message}",
            llm_provider=custom_llm_provider,
            model=model,
            litellm_debug_info=extra_information,
            response=getattr(original_exception, "response", None),
        )
    elif "Connection error" in error_str:
        raise APIConnectionError(
            message=f"{exception_provider} APIConnectionError - {message}",
            llm_provider=custom_llm_provider,
            model=model,
            litellm_debug_info=extra_information,
        )
    elif hasattr(original_exception, "status_code"):
        if original_exception.status_code == 400:
            raise BadRequestError(
                message=f"AzureException - {message}",
                llm_provider="azure",
                model=model,
                litellm_debug_info=extra_information,
                response=getattr(original_exception, "response", None),
                body=getattr(original_exception, "body", None),
            )
        elif original_exception.status_code == 401:
            raise AuthenticationError(
                message=f"AzureException AuthenticationError - {message}",
                llm_provider="azure",
                model=model,
                litellm_debug_info=extra_information,
                response=getattr(original_exception, "response", None),
            )
        elif original_exception.status_code == 404:
            raise NotFoundError(
                message=f"AzureException NotFoundError - {message}",

View on GitHub (pinned to 77b7c6c40c)