BerriAI/litellm · error · AuthenticationError

str(e)

Error message

str(e)

What it means

Same pattern as 1416 but on the Responses API path: `GetAccessTokenError` from `get_access_token()` is re-wrapped as `AuthenticationError` (provider `chatgpt`) with the original message. It fires in `validate_environment` when building request headers, before any model call is sent.

Source

Thrown at litellm/llms/chatgpt/responses/transformation.py:50

class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig):
    def __init__(self) -> None:
        super().__init__()
        self.authenticator = Authenticator()

    @property
    def custom_llm_provider(self) -> LlmProviders:
        return LlmProviders.CHATGPT

    def validate_environment(
        self,
        headers: dict,
        model: str,
        litellm_params: GenericLiteLLMParams | None,
    ) -> dict:
        try:
            access_token: Final = self.authenticator.get_access_token()
        except GetAccessTokenError as e:
            raise AuthenticationError(
                model=model,
                llm_provider="chatgpt",
                message=str(e),
            )

        account_id: Final = self.authenticator.get_account_id()
        session_id: Final = ensure_chatgpt_session_id(litellm_params)
        default_headers: Final = get_chatgpt_default_headers(access_token, account_id, session_id)
        return {**default_headers, **headers}

    def transform_responses_api_request(
        self,
        model: str,
        input: Any,
        response_api_optional_request_params: dict,
        litellm_params: GenericLiteLLMParams,
        headers: dict,
    ) -> dict:

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Run the ChatGPT device login to create/refresh the stored credentials, then retry the responses call.
  2. Verify the auth file exists and is readable by the process (permissions, correct HOME dir in containers).
  3. Re-login if the message indicates refresh failure or invalid grant.
  4. Fall back to `openai/...` with an API key if OAuth is impractical in your deployment.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    resp = litellm.responses(model="chatgpt/...", input="hi")
except litellm.AuthenticationError as e:
    logger.error("chatgpt responses auth failure: %s", str(e))
    raise

Prevention

When it happens

Trigger: Calling `litellm.responses(..., model="chatgpt/...")` (or the responses endpoint) with missing, expired, or unrefreshable OAuth tokens. The underlying cause is any of the device-flow/refresh errors (1404–1415).

Common situations: Using ChatGPT Plus/Teams OAuth via the Responses API in environments without completed login; auth file deleted or corrupted; refresh token revoked after password change or logout.

Related errors


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