{"record":{"id":"fffc4c98e6773253","repo":"BerriAI/litellm","slug":"error-in-response-raw-response-error","errorCode":null,"errorMessage":"Error in response: {raw_response.error}","messagePattern":"Error in response: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/transformation.py","lineNumber":745,"sourceCode":"        model_response: \"ModelResponse\",\n        logging_obj: \"LiteLLMLoggingObj\",\n        request_data: dict,\n        messages: list[\"AllMessageValues\"],\n        optional_params: dict,\n        litellm_params: dict,\n        encoding: object,\n        api_key: str | None = None,\n        json_mode: bool | None = None,\n    ) -> \"ModelResponse\":\n        \"\"\"Transform Responses API response to chat completion response\"\"\"\n        from litellm.responses.utils import ResponseAPILoggingUtils\n        from litellm.types.llms.openai import ResponsesAPIResponse\n\n        if not isinstance(raw_response, ResponsesAPIResponse):\n            raise ValueError(f\"Unexpected response type: {type(raw_response)}\")\n\n        if raw_response.error is not None:\n            raise ValueError(f\"Error in response: {raw_response.error}\")\n\n        output_items = raw_response.output\n        if len(output_items) == 0:\n            recovered_output_items: Final = self._recover_output_items_from_logging(logging_obj)\n            if recovered_output_items:\n                output_items = cast(Any, recovered_output_items)\n                raw_response.output = cast(Any, recovered_output_items)\n                verbose_logger.warning(\n                    \"Recovered empty Responses API output from raw SSE for model=%s\",\n                    model,\n                )\n\n        # Convert response output to choices using the static helper\n        choices: Final = self._convert_response_output_to_choices(\n            output_items=output_items,\n            handle_raw_dict_callback=self._handle_raw_dict_response_item,\n        )\n","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/completion_extras/litellm_responses_transformation/transformation.py#L727-L763","documentation":"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.","triggerScenarios":"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.","commonSituations":"Misconfigured credentials on some gateways; region-locked or deactivated models; transient upstream errors; quota issues delivered as in-band errors.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"def response_has_error(parsed) -> bool:\n    return getattr(parsed, \"error\", None) is not None","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=m, messages=msgs)\nexcept ValueError as e:\n    if str(e).startswith(\"Error in response:\"):\n        # in-band provider error: inspect text, retry transient causes, fail over for auth/quota\n        handle_provider_error(str(e))\n    raise","preventionTips":["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"],"tags":["responses-api","provider-error","in-band-error"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}