{"record":{"id":"c7b88e19fb048f20","repo":"BerriAI/litellm","slug":"replicateexception-original-exception","errorCode":null,"errorMessage":"ReplicateException - {original_exception}","messagePattern":"ReplicateException - (.+?)","errorType":"exception","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":687,"sourceCode":"                message=f\"ReplicateException - {original_exception.message}\",\n                model=model,\n                llm_provider=\"replicate\",\n            )\n        elif original_exception.status_code == 429:\n            raise RateLimitError(\n                message=f\"ReplicateException - {original_exception.message}\",\n                llm_provider=\"replicate\",\n                model=model,\n                response=getattr(original_exception, \"response\", None),\n            )\n        elif original_exception.status_code == 500:\n            raise ServiceUnavailableError(\n                message=f\"ReplicateException - {original_exception.message}\",\n                llm_provider=\"replicate\",\n                model=model,\n                response=getattr(original_exception, \"response\", None),\n            )\n    raise APIError(\n        status_code=500,\n        message=f\"ReplicateException - {original_exception}\",\n        llm_provider=\"replicate\",\n        model=model,\n        request=httpx.Request(\n            method=\"POST\",\n            url=\"https://api.replicate.com/v1/deployments\",\n        ),\n    )\n\n\ndef _map_openai_like_exception(\n    *,\n    model: str,\n    original_exception: _ProviderHTTPException,\n    custom_llm_provider: str,\n    error_str: str,\n    exception_type: str,","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L669-L705","documentation":"This is the catch-all at the end of _map_replicate_exception: any Replicate exception that matched no known error string or status code becomes a generic litellm.APIError with status_code 500 and a synthetic httpx.Request to https://api.replicate.com/v1/deployments. It signals an unrecognized error shape; the real cause lives only in the stringified original exception inside the message, so treat that text as the source of truth.","triggerScenarios":"Replicate SDK errors without a status_code attribute (network-level failures, connection resets, DNS faults); new SDK error classes litellm has not mapped yet; HTML error bodies that parse into none of the known patterns.","commonSituations":"Upgrading the replicate package introduces new exception classes; corporate proxies breaking connections; transient network issues surfacing as opaque errors.","solutions":["Log the full message plus your replicate/litellm versions - the stringified original exception is the only diagnostic","Reproduce against Replicate directly with the same SDK call","Upgrade litellm - newer releases add mappings for previously unrecognized exceptions","If the underlying cause is network flakiness, wrap the call in retries"],"exampleFix":"# before - opaque APIError swallowed\ntry:\n    resp = litellm.completion(model=model, messages=messages)\nexcept Exception:\n    pass\n\n# after - capture the underlying cause for diagnosis\ntry:\n    resp = litellm.completion(model=model, messages=messages)\nexcept litellm.APIError as e:\n    logger.error(\"unmapped replicate failure: %s\", e.message)\n    raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import litellm\n\ndef is_unmapped_replicate_error(exc: BaseException) -> bool:\n    return (\n        isinstance(exc, litellm.APIError)\n        and getattr(exc, \"llm_provider\", \"\") == \"replicate\"\n        and not isinstance(exc, (\n            litellm.BadRequestError,\n            litellm.AuthenticationError,\n            litellm.RateLimitError,\n            litellm.Timeout,\n            litellm.ServiceUnavailableError,\n        ))\n    )","tryCatchPattern":"try:\n    resp = litellm.completion(model=model, messages=messages)\nexcept litellm.APIError as e:\n    # last-resort branch: message contains the stringified Replicate exception\n    capture_diagnostic({\"error\": e.message, \"model\": model})\n    raise","preventionTips":["Always log the full exception message for unmapped provider errors","Keep litellm current so new provider exceptions get mapped","Wrap provider calls with structured error reporting"],"tags":["litellm","replicate","catch-all","api-error","unknown-error"],"backgroundTag":"unhandled-provider-error","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}