{"record":{"id":"5c47a6f2b997b019","repo":"BerriAI/litellm","slug":"anthropicexception-badgatewayerror-error-str","errorCode":null,"errorMessage":"AnthropicException BadGatewayError - {error_str}","messagePattern":"AnthropicException BadGatewayError - (.+?)","errorType":"exception","errorClass":"BadGatewayError","httpStatus":502,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":585,"sourceCode":"                message=f\"AnthropicException - {error_str}\",\n                model=model,\n                llm_provider=\"anthropic\",\n            )\n        elif original_exception.status_code == 429:\n            raise RateLimitError(\n                message=f\"AnthropicException - {error_str}\",\n                llm_provider=\"anthropic\",\n                model=model,\n            )\n        elif original_exception.status_code == 500 or original_exception.status_code == 529:\n            raise litellm.InternalServerError(\n                message=f\"AnthropicException - {error_str}. Handle with `litellm.InternalServerError`.\",\n                llm_provider=\"anthropic\",\n                model=model,\n                response=getattr(original_exception, \"response\", None),\n            )\n        elif original_exception.status_code == 502:\n            raise BadGatewayError(\n                message=f\"AnthropicException BadGatewayError - {error_str}\",\n                llm_provider=\"anthropic\",\n                model=model,\n                response=getattr(original_exception, \"response\", None),\n            )\n        elif original_exception.status_code == 503:\n            raise litellm.ServiceUnavailableError(\n                message=f\"AnthropicException - {error_str}. Handle with `litellm.ServiceUnavailableError`.\",\n                llm_provider=\"anthropic\",\n                model=model,\n                response=getattr(original_exception, \"response\", None),\n            )\n        elif original_exception.status_code == 504:  # gateway timeout error\n            raise Timeout(\n                message=f\"AnthropicException Timeout - {error_str}\",\n                model=model,\n                llm_provider=\"anthropic\",\n                exception_status_code=original_exception.status_code,","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/exception_mapping_utils.py#L567-L603","documentation":"Error \"AnthropicException BadGatewayError - {error_str}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:585 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Anthropic gateway error; retry with backoff."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}