BerriAI/litellm · error · BadGatewayError
AnthropicException BadGatewayError
Error message
AnthropicException BadGatewayError - {error_str} What it means
Anthropic-specific status mapping: an upstream Anthropic error with HTTP 502 is re-raised as BadGatewayError with the 'AnthropicException' prefix, signaling a gateway-level failure between LiteLLM and Anthropic.
Solutions
- Anthropic's gateway returned an error; retry with backoff.
- Check https://status.anthropic.com for incidents.
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:585 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/5c47a6f2b997b019.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:585
message=f"AnthropicException - {error_str}",
model=model,
llm_provider="anthropic",
)
elif original_exception.status_code == 429:
raise RateLimitError(
message=f"AnthropicException - {error_str}",
llm_provider="anthropic",
model=model,
)
elif original_exception.status_code == 500 or original_exception.status_code == 529:
raise litellm.InternalServerError(
message=f"AnthropicException - {error_str}. Handle with `litellm.InternalServerError`.",
llm_provider="anthropic",
model=model,
response=getattr(original_exception, "response", None),
)
elif original_exception.status_code == 502:
raise BadGatewayError(
message=f"AnthropicException BadGatewayError - {error_str}",
llm_provider="anthropic",
model=model,
response=getattr(original_exception, "response", None),
)
elif original_exception.status_code == 503:
raise litellm.ServiceUnavailableError(
message=f"AnthropicException - {error_str}. Handle with `litellm.ServiceUnavailableError`.",
llm_provider="anthropic",
model=model,
response=getattr(original_exception, "response", None),
)
elif original_exception.status_code == 504: # gateway timeout error
raise Timeout(
message=f"AnthropicException Timeout - {error_str}",
model=model,
llm_provider="anthropic",
exception_status_code=original_exception.status_code,View on GitHub (pinned to 77b7c6c40c)