BerriAI/litellm · error · BaseLLMException

{error_message}

Error message

{error_message}

What it means

This is the generic error path of the BaseResponsesAPIConfig for LiteLLM's Responses API. When a provider returns a non-2xx HTTP response during a /v1/responses call, LiteLLM builds a BaseLLMException from the provider's error message, HTTP status code, and response headers. The '{error_message}' placeholder in the traceback is the upstream provider's own error text (e.g. an OpenAI-style 'invalid_request_error' body). It usually surfaces to callers as a litellm exception mapped from the status code (400/401/429/500 etc.).

Source

Thrown at litellm/llms/base_llm/responses/transformation.py:229

    ) -> tuple[str, dict]:
        pass

    @abstractmethod
    def transform_list_input_items_response(
        self,
        raw_response: httpx.Response,
        logging_obj: LiteLLMLoggingObj,
    ) -> dict:
        pass

    #########################################################
    ########## END GET RESPONSE API TRANSFORMATION ##########
    #########################################################

    def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:
        from ..chat.transformation import BaseLLMException

        raise BaseLLMException(
            status_code=status_code,
            message=error_message,
            headers=headers,
        )

    def should_fake_stream(
        self,
        model: str | None,
        stream: bool | None,
        custom_llm_provider: str | None = None,
    ) -> bool:
        """Returns True if litellm should fake a stream for the given model and stream value"""
        return False

    def supports_native_websocket(self) -> bool:
        """
        Returns True if the provider has a native WebSocket endpoint for Responses API.

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Read the full provider message and status_code carried in the exception (and the headers) — the fix is almost always upstream (auth, model name, payload), not in litellm itself.
  2. Verify the API key for the provider is set and valid (e.g. os.environ['OPENAI_API_KEY']) and that 'model' is spelled '<provider>/<model>' correctly.
  3. Reproduce the same request with the provider's native SDK or curl to confirm whether the error is a litellm mapping issue or a genuine provider rejection.
  4. For 429s add retry_with_fallback or configure num_retries/cooling_time; for 401/403 rotate credentials.
  5. If the error body is truncated or unhelpful, enable litellm.debug_logger or set LITELLM_LOG=DEBUG to inspect the raw response.

Example fix

# before
resp = litellm.responses(model="openai/gpt-4o", input="hi")

# after: catch and inspect status + provider message
import litellm
from litellm.llms.base_llm.chat.transformation import BaseLLMException

try:
    resp = litellm.responses(model="openai/gpt-4o", input="hi")
except BaseLLMException as e:
    print(e.status_code, e.message)  # e.g. 401 'Incorrect API key provided'
Defensive patterns

Strategy: try-catch

Validate before calling

import litellm

# validate model exists and key is present before calling
assert litellm.validate_environment(model="openai/gpt-4o"), "missing credentials for provider"

Type guard

from litellm.llms.base_llm.chat.transformation import BaseLLMException

def is_responses_provider_error(e: BaseException) -> bool:
    return isinstance(e, BaseLLMException) and hasattr(e, "status_code")

Try / catch

try:
    resp = litellm.responses(model="openai/gpt-4o", input="hi")
except BaseLLMException as e:
    if e.status_code == 429:
        backoff_and_retry()
    elif e.status_code in (401, 403):
        rotate_credentials()
    else:
        raise

Prevention

When it happens

Trigger: Calling litellm.responses() (or a provider's Responses API transformation) where the upstream request fails: invalid model name, expired/incorrect API key (401), rate limit (429), malformed input_params, or a provider outage (5xx). The transformation layer catches the failed HTTP response and invokes get_error_class(), which raises BaseLLMException with the provider's message verbatim.

Common situations: Typos in the model name; missing or wrong OPENAI_API_KEY/generic API key env var; hitting org rate limits; sending Responses-API-specific params the provider rejects; proxy misrouting to a wrong endpoint; provider version changes deprecating a parameter.

Related errors


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