BerriAI/litellm · error · ContextWindowExceededError

{error_str}

Error message

{error_str}

What it means

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

Source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:1428

                llm_provider="cohere",
                model=model,
                request=getattr(original_exception, "request", None),
            )
        raise cast(Exception, original_exception)


def _map_huggingface_exception(
    *,
    model: str,
    original_exception: _ProviderHTTPException,
    custom_llm_provider: str,
    error_str: str,
    exception_type: str,
    exception_provider: str,
    extra_information: str,
) -> None:
    if "length limit exceeded" in error_str:
        raise ContextWindowExceededError(
            message=error_str,
            model=model,
            llm_provider="huggingface",
            response=getattr(original_exception, "response", None),
        )
    elif "A valid user token is required" in error_str:
        raise BadRequestError(
            message=error_str,
            llm_provider="huggingface",
            model=model,
            response=getattr(original_exception, "response", None),
        )
    elif "Rate limit reached" in error_str:
        raise RateLimitError(
            message=error_str,
            llm_provider="huggingface",
            model=model,
            response=getattr(original_exception, "response", None),

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Inspect the error string from the provider and adjust the request.

When it happens

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