BerriAI/litellm · error · BadGatewayError
BadGatewayError
Error message
BadGatewayError: {exception_provider} - {message} What it means
Generic provider status-code mapping: an upstream exception with HTTP 502 is re-raised as LiteLLM's BadGatewayError, signaling an upstream proxy/gateway failure rather than a LiteLLM fault.
Solutions
- Bad gateway from the provider/upstream; retry after a short delay.
- Check provider status and any intermediary proxies/gateways.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:457 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/9a52c5ee23a36bea.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:457
)
elif original_exception.status_code == 429:
raise RateLimitError(
message=f"RateLimitError: {exception_provider} - {message}",
model=model,
llm_provider=custom_llm_provider,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif original_exception.status_code == 500:
raise InternalServerError(
message=f"InternalServerError: {exception_provider} - {message}",
model=model,
llm_provider=custom_llm_provider,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif original_exception.status_code == 502:
raise BadGatewayError(
message=f"BadGatewayError: {exception_provider} - {message}",
model=model,
llm_provider=custom_llm_provider,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif original_exception.status_code == 503:
raise ServiceUnavailableError(
message=f"ServiceUnavailableError: {exception_provider} - {message}",
model=model,
llm_provider=custom_llm_provider,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif original_exception.status_code == 504: # gateway timeout error
raise Timeout(
message=f"Timeout Error: {exception_provider} - {message}",
model=model,View on GitHub (pinned to 77b7c6c40c)