BerriAI/litellm · error · ContextWindowExceededError

AnthropicError - {error_str}

Error message

AnthropicError - {error_str}

What it means

Error "AnthropicError - {error_str}" thrown in BerriAI/litellm.

Source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:516

        )


def _map_anthropic_exception(
    *,
    model: str,
    original_exception: _ProviderHTTPException,
    custom_llm_provider: str,
    error_str: str,
    exception_type: str,
    exception_provider: str,
    extra_information: str,
) -> None:
    if (
        "prompt is too long" in error_str
        or "prompt: length" in error_str
        or ExceptionCheckers.is_error_str_context_window_exceeded(error_str)
    ):
        raise ContextWindowExceededError(
            message=f"AnthropicError - {error_str}",
            model=model,
            llm_provider="anthropic",
        )
    elif "overloaded_error" in error_str or "Overloaded" in error_str:
        raise InternalServerError(
            message=f"AnthropicError - {error_str}",
            model=model,
            llm_provider="anthropic",
        )
    if "Invalid API Key" in error_str:
        raise AuthenticationError(
            message=f"AnthropicError - {error_str}",
            model=model,
            llm_provider="anthropic",
        )
    if "content filtering policy" in error_str:
        raise ContentPolicyViolationError(

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Inspect the Anthropic error string; adjust the request or credentials accordingly.

When it happens

Trigger: Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:516 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/9e286ac2fb7e4b9c. Report an issue: GitHub.