BerriAI/litellm · error · APIError

ReplicateException

Error message

ReplicateException - {original_exception}

What it means

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.

Solutions

  1. Log the full message plus your replicate/litellm versions - the stringified original exception is the only diagnostic
  2. Reproduce against Replicate directly with the same SDK call
  3. Upgrade litellm - newer releases add mappings for previously unrecognized exceptions
  4. If the underlying cause is network flakiness, wrap the call in retries

Example fix

# before - opaque APIError swallowed
try:
    resp = litellm.completion(model=model, messages=messages)
except Exception:
    pass

# after - capture the underlying cause for diagnosis
try:
    resp = litellm.completion(model=model, messages=messages)
except litellm.APIError as e:
    logger.error("unmapped replicate failure: %s", e.message)
    raise
Defensive patterns

Strategy: try-catch

Type guard

import litellm

def is_unmapped_replicate_error(exc: BaseException) -> bool:
    return (
        isinstance(exc, litellm.APIError)
        and getattr(exc, "llm_provider", "") == "replicate"
        and not isinstance(exc, (
            litellm.BadRequestError,
            litellm.AuthenticationError,
            litellm.RateLimitError,
            litellm.Timeout,
            litellm.ServiceUnavailableError,
        ))
    )

Try / catch

try:
    resp = litellm.completion(model=model, messages=messages)
except litellm.APIError as e:
    # last-resort branch: message contains the stringified Replicate exception
    capture_diagnostic({"error": e.message, "model": model})
    raise

Prevention

When it happens

Trigger: 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.

Common situations: Upgrading the replicate package introduces new exception classes; corporate proxies breaking connections; transient network issues surfacing as opaque errors.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/c7b88e19fb048f20. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:687

                message=f"ReplicateException - {original_exception.message}",
                model=model,
                llm_provider="replicate",
            )
        elif original_exception.status_code == 429:
            raise RateLimitError(
                message=f"ReplicateException - {original_exception.message}",
                llm_provider="replicate",
                model=model,
                response=getattr(original_exception, "response", None),
            )
        elif original_exception.status_code == 500:
            raise ServiceUnavailableError(
                message=f"ReplicateException - {original_exception.message}",
                llm_provider="replicate",
                model=model,
                response=getattr(original_exception, "response", None),
            )
    raise APIError(
        status_code=500,
        message=f"ReplicateException - {original_exception}",
        llm_provider="replicate",
        model=model,
        request=httpx.Request(
            method="POST",
            url="https://api.replicate.com/v1/deployments",
        ),
    )


def _map_openai_like_exception(
    *,
    model: str,
    original_exception: _ProviderHTTPException,
    custom_llm_provider: str,
    error_str: str,
    exception_type: str,

View on GitHub (pinned to 77b7c6c40c)