{"record":{"id":"bc25e3963afc51ae","repo":"BerriAI/litellm","slug":"error-message-bc25e3","errorCode":null,"errorMessage":"error_message","messagePattern":"error_message","errorType":"http","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"litellm/llms/openai/chat/gpt_transformation.py","lineNumber":794,"sourceCode":"        \"\"\"OpenAI-compatible backends (vLLM, sglang) can return an HTTP 200\n        stream whose body carries an error payload, e.g.\n        ``data: {\"error\": {\"message\": \"...\", \"code\": 400}}``.\"\"\"\n        error: Final = chunk.get(\"error\")\n        if not error:\n            return None\n        if not isinstance(error, dict):\n            return str(error), 500\n        message: Final = error.get(\"message\")\n        code: Final = error.get(\"code\")\n        status_code: Final = code if isinstance(code, int) and 400 <= code < 600 else 500\n        return (message if isinstance(message, str) else json.dumps(error)), status_code\n\n    def chunk_parser(self, chunk: dict) -> ModelResponseStream:\n        try:\n            error_details: Final = self._extract_error_from_chunk(chunk)\n            if error_details is not None:\n                error_message, error_status_code = error_details\n                raise OpenAIError(\n                    status_code=error_status_code,\n                    message=error_message,\n                )\n            choices = chunk.get(\"choices\", [])\n            choices = self._map_reasoning_to_reasoning_content(choices)\n\n            kwargs: Final[dict[str, Any]] = {\n                \"id\": chunk.get(\"id\"),\n                \"object\": \"chat.completion.chunk\",\n                \"created\": chunk.get(\"created\"),\n                \"model\": chunk.get(\"model\"),\n                \"choices\": choices,\n            }\n            if \"usage\" in chunk and chunk[\"usage\"] is not None:\n                kwargs[\"usage\"] = chunk[\"usage\"]\n            return ModelResponseStream(**kwargs)\n        except Exception as e:\n            raise e","sourceCodeStart":776,"sourceCodeEnd":812,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/openai/chat/gpt_transformation.py#L776-L812","documentation":"Extracted error message from an SSE chunk emitted by OpenAI-compatible backends (vLLM, sglang) that return HTTP 200 streams whose payloads carry an error object instead of deltas. The message is the provider's own error text (or a JSON dump of the non-string error), paired with a status code derived from the payload's 'code' field or defaulted to 500.","triggerScenarios":"Thrown at litellm/llms/openai/chat/gpt_transformation.py:794 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the error message included in the exception and correct the OpenAI request accordingly."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}