BerriAI/litellm · error · AuthenticationError

AnthropicException

Error message

AnthropicException - {error_str}

What it means

Anthropic-specific catch-all: after specific branches (status codes, prompt length, content filter), any remaining AnthropicException is re-raised as a generic litellm exception with the raw error string preserved, so unclassified provider errors are not silently dropped.

Solutions

  1. Review the Anthropic error string and fix the offending request field.
  2. Check the Anthropic API status if the error is server-side.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:548 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/a437e00c5ab6b924. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:548

            model=model,
            llm_provider="anthropic",
        )
    if "content filtering policy" in error_str:
        raise ContentPolicyViolationError(
            message=f"AnthropicError - {error_str}",
            model=model,
            llm_provider="anthropic",
        )
    if "Client error '400 Bad Request'" in error_str:
        raise BadRequestError(
            message=f"AnthropicError - {error_str}",
            model=model,
            llm_provider="anthropic",
        )
    if hasattr(original_exception, "status_code"):
        verbose_logger.debug("status_code: %s", original_exception.status_code)
        if original_exception.status_code == 401:
            raise AuthenticationError(
                message=f"AnthropicException - {error_str}",
                llm_provider="anthropic",
                model=model,
            )
        elif original_exception.status_code == 400 or original_exception.status_code == 413:
            raise BadRequestError(
                message=f"AnthropicException - {error_str}",
                model=model,
                llm_provider="anthropic",
            )
        elif original_exception.status_code == 404:
            raise NotFoundError(
                message=f"AnthropicException - {error_str}",
                model=model,
                llm_provider="anthropic",
            )
        elif original_exception.status_code == 408:
            raise Timeout(

View on GitHub (pinned to 77b7c6c40c)