BerriAI/litellm · error · ContextWindowExceededError

this is a mock context window exceeded error

Error message

this is a mock context window exceeded error

What it means

Error "this is a mock context window exceeded error" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/anthropic/experimental_pass_through/messages/utils.py:80

    **kwargs,
) -> AnthropicMessagesResponse:
    """
    Mock response for Anthropic messages
    """
    from litellm.exceptions import (
        ContextWindowExceededError,
        InternalServerError,
        RateLimitError,
    )

    if mock_response == "litellm.InternalServerError":
        raise InternalServerError(
            message="this is a mock internal server error",
            llm_provider="anthropic",
            model=model,
        )
    elif mock_response == "litellm.ContextWindowExceededError":
        raise ContextWindowExceededError(
            message="this is a mock context window exceeded error",
            llm_provider="anthropic",
            model=model,
        )
    elif mock_response == "litellm.RateLimitError":
        raise RateLimitError(
            message="this is a mock rate limit error",
            llm_provider="anthropic",
            model=model,
        )
    return AnthropicMessagesResponse(
        **{
            "content": [{"text": mock_response, "type": "text"}],
            "id": "msg_013Zva2CMHLNnXjNJJKqJ2EF",
            "model": "claude-sonnet-4-20250514",
            "role": "assistant",
            "stop_reason": "end_turn",
            "stop_sequence": None,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. This is a test/mock error raised intentionally; remove the mock trigger from your request or test setup.

When it happens

Trigger: Thrown at litellm/llms/anthropic/experimental_pass_through/messages/utils.py:80 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/5af0f86c37eeb6cc. Report an issue: GitHub.