BerriAI/litellm · error · AuthenticationError

AuthenticationError

Error message

AuthenticationError: {exception_provider} - {message}

What it means

Exception-mapping branch: when the error string indicates missing/invalid credentials, the original exception is re-raised as litellm AuthenticationError, telling callers the configured API key was rejected or absent.

Solutions

  1. Check the API key for the provider: it is missing, invalid, or expired.
  2. Set the correct key via environment variable or the api_key parameter.
Defensive patterns

Strategy: validation

When it happens

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

Common situations: See trigger scenarios.

Understand the failure class


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

Appendix: source

Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:382

    ):
        raise litellm.InternalServerError(
            message=f"{exception_provider} - {message}",
            model=model,
            llm_provider=custom_llm_provider,
        )
    elif "Request too large" in error_str:
        raise RateLimitError(
            message=f"RateLimitError: {exception_provider} - {message}",
            model=model,
            llm_provider=custom_llm_provider,
            response=getattr(original_exception, "response", None),
            litellm_debug_info=extra_information,
        )
    elif (
        "The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable"
        in error_str
    ):
        raise AuthenticationError(
            message=f"AuthenticationError: {exception_provider} - {message}",
            llm_provider=custom_llm_provider,
            model=model,
            response=getattr(original_exception, "response", None),
            litellm_debug_info=extra_information,
        )
    elif "Mistral API raised a streaming error" in error_str:
        _request: Final = httpx.Request(method="POST", url="https://api.openai.com/v1")
        raise APIError(
            status_code=500,
            message=f"{exception_provider} - {message}",
            llm_provider=custom_llm_provider,
            model=model,
            request=_request,
            litellm_debug_info=extra_information,
        )
    elif hasattr(original_exception, "status_code"):
        if original_exception.status_code == 400:

View on GitHub (pinned to 77b7c6c40c)