BerriAI/litellm · error · ValueError
Error in response: {raw_response.error}
Error message
Error in response: {raw_response.error} What it means
transform_response raises this when the parsed ResponsesAPIResponse carries a non-null error field — the provider accepted the HTTP request but embedded an error object in the response body (common with the Responses API: 200 OK plus response.error). The message includes the provider's error payload verbatim.
Source
Thrown at litellm/completion_extras/litellm_responses_transformation/transformation.py:745
model_response: "ModelResponse",
logging_obj: "LiteLLMLoggingObj",
request_data: dict,
messages: list["AllMessageValues"],
optional_params: dict,
litellm_params: dict,
encoding: object,
api_key: str | None = None,
json_mode: bool | None = None,
) -> "ModelResponse":
"""Transform Responses API response to chat completion response"""
from litellm.responses.utils import ResponseAPILoggingUtils
from litellm.types.llms.openai import ResponsesAPIResponse
if not isinstance(raw_response, ResponsesAPIResponse):
raise ValueError(f"Unexpected response type: {type(raw_response)}")
if raw_response.error is not None:
raise ValueError(f"Error in response: {raw_response.error}")
output_items = raw_response.output
if len(output_items) == 0:
recovered_output_items: Final = self._recover_output_items_from_logging(logging_obj)
if recovered_output_items:
output_items = cast(Any, recovered_output_items)
raw_response.output = cast(Any, recovered_output_items)
verbose_logger.warning(
"Recovered empty Responses API output from raw SSE for model=%s",
model,
)
# Convert response output to choices using the static helper
choices: Final = self._convert_response_output_to_choices(
output_items=output_items,
handle_raw_dict_callback=self._handle_raw_dict_response_item,
)
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Read the embedded error message — it is the provider's own text and names the root cause
- For auth/quota errors, verify API key and billing, then retry
- For transient upstream errors, retry with backoff or fail over to another deployment via litellm Router
- If using a proxy/gateway, check its logs for the upstream exchange
Defensive patterns
Strategy: try-catch
Validate before calling
def response_has_error(parsed) -> bool:
return getattr(parsed, "error", None) is not None Try / catch
try:
resp = litellm.completion(model=m, messages=msgs)
except ValueError as e:
if str(e).startswith("Error in response:"):
# in-band provider error: inspect text, retry transient causes, fail over for auth/quota
handle_provider_error(str(e))
raise Prevention
- Treat in-band errors like HTTP errors: classify by content (auth, quota, content policy)
- Use litellm Router with fallbacks so in-band errors trigger the next deployment
- Log raw responses via callbacks to capture the provider's error payload
When it happens
Trigger: Provider returns 200 with an error object: invalid API key surfaced late, content policy violations, model access denied, or upstream failures reported in-band instead of via HTTP status.
Common situations: Misconfigured credentials on some gateways; region-locked or deactivated models; transient upstream errors; quota issues delivered as in-band errors.
Related errors
- {error_message}
- Unexpected responses stream payload
- Stream ended without a completed response
- Stream completed response is invalid
- tool call not supported: {tool_call}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/fffc4c98e6773253.
Report an issue: GitHub.