BerriAI/litellm · error · ServiceUnavailableError

AzureException ServiceUnavailableError

Error message

AzureException ServiceUnavailableError - {message}

What it means

Azure-specific status mapping: an upstream Azure exception with HTTP 502 is re-raised as BadGatewayError, signaling an infrastructure/gateway failure on Azure's side rather than a bad request.

Solutions

  1. The Azure service is temporarily unavailable; retry with backoff.
  2. Configure fallbacks to another deployment or region.
Defensive patterns

Strategy: retry

When it happens

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

Appendix: source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:2035

            )
        elif original_exception.status_code == 429:
            raise RateLimitError(
                message=f"AzureException RateLimitError - {message}",
                model=model,
                llm_provider="azure",
                litellm_debug_info=extra_information,
                response=getattr(original_exception, "response", None),
            )
        elif original_exception.status_code == 502:
            raise BadGatewayError(
                message=f"AzureException BadGatewayError - {message}",
                model=model,
                llm_provider="azure",
                litellm_debug_info=extra_information,
                response=getattr(original_exception, "response", None),
            )
        elif original_exception.status_code == 503:
            raise ServiceUnavailableError(
                message=f"AzureException ServiceUnavailableError - {message}",
                model=model,
                llm_provider="azure",
                litellm_debug_info=extra_information,
                response=getattr(original_exception, "response", None),
            )
        elif original_exception.status_code == 504:  # gateway timeout error
            raise Timeout(
                message=f"AzureException Timeout - {message}",
                model=model,
                litellm_debug_info=extra_information,
                llm_provider="azure",
                exception_status_code=original_exception.status_code,
            )
        else:
            raise APIError(
                status_code=original_exception.status_code,
                message=f"AzureException APIError - {message}",

View on GitHub (pinned to 77b7c6c40c)