{"record":{"id":"841c359ab21a1649","repo":"BerriAI/litellm","slug":"e-original-response-response-text","errorCode":null,"errorMessage":"{e}\n\nOriginal Response: {response.text}","messagePattern":"(.+?)\n\nOriginal Response: (.+?)","errorType":"http","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"litellm/llms/openai/openai.py","lineNumber":1101,"sourceCode":"                ## check if body contains unprocessable params - related issue https://github.com/BerriAI/litellm/issues/4800\n                if litellm.drop_params is True or drop_params is True:\n                    data = drop_params_from_unprocessable_entity_error(e, data)\n                else:\n                    raise e\n            except (\n                Exception\n            ) as e:  # need to exception handle here. async exceptions don't get caught in sync functions.\n                if isinstance(e, OpenAIError):\n                    raise e\n\n                error_headers = getattr(e, \"headers\", None)\n                status_code = getattr(e, \"status_code\", 500)\n                error_response = getattr(e, \"response\", None)\n                exception_body = getattr(e, \"body\", None)\n                if error_headers is None and error_response:\n                    error_headers = getattr(error_response, \"headers\", None)\n                if response is not None and hasattr(response, \"text\"):\n                    raise OpenAIError(\n                        status_code=status_code,\n                        message=f\"{e}\\n\\nOriginal Response: {response.text}\",\n                        headers=error_headers,\n                        body=exception_body,\n                    )\n                else:\n                    if type(e).__name__ == \"ReadTimeout\":\n                        raise OpenAIError(\n                            status_code=408,\n                            message=f\"{type(e).__name__}\",\n                            headers=error_headers,\n                            body=exception_body,\n                        )\n                    elif hasattr(e, \"status_code\"):\n                        raise OpenAIError(\n                            status_code=getattr(e, \"status_code\", 500),\n                            message=str(e),\n                            headers=error_headers,","sourceCodeStart":1083,"sourceCodeEnd":1119,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/openai/openai.py#L1083-L1119","documentation":"Error branch in streaming() (litellm/llms/openai/openai.py:1101) taken when the request failed but an httpx response with .text exists: litellm raises OpenAIError with message '<exception>\\n\\nOriginal Response: <response.text>' plus the upstream status, headers and body. The appended Original Response is the raw error body — typically a proxy's HTML error page or the provider's JSON error object — and is the primary diagnostic.","triggerScenarios":"Streaming calls where the server answers non-200 with a body: nginx/traefik 502/504 HTML pages, OpenAI JSON errors (invalid_api_key, model_not_found), gateways returning HTML 404s because the api_base path is wrong, WAFs intercepting streaming POSTs.","commonSituations":"api_base missing /v1 so the path 404s with HTML; upstream LLM unavailable behind a load balancer; auth failures; corporate proxies blocking SSE.","solutions":["Read the 'Original Response:' section — HTML means proxy/routing problem, JSON means provider error with a code","Fix api_base so it resolves to the real /v1/chat/completions route","If it is a 502/504 from a proxy, fix or bypass the proxy","Map the status_code plus the JSON error code to the concrete fix (key, model, quota)"],"exampleFix":"# before\nlitellm.completion(model='gpt-4o', messages=msgs, stream=True, api_base='https://gw.internal')\n\n# after\nlitellm.completion(model='gpt-4o', messages=msgs, stream=True, api_base='https://gw.internal/v1')","handlingStrategy":"try-catch","validationCode":"import httpx\n\ndef stream_endpoint_ok(api_base: str, api_key: str) -> bool:\n    r = httpx.post(\n        f'{api_base.rstrip(\"/\")}/chat/completions',\n        headers={'Authorization': f'Bearer {api_key}'},\n        json={'model': 'ping', 'messages': [{'role': 'user', 'content': 'ping'}], 'stream': True},\n        timeout=15,\n    )\n    return r.status_code == 200 and 'text/event-stream' in r.headers.get('content-type', '')","typeGuard":null,"tryCatchPattern":"from litellm.llms.openai.common_utils import OpenAIError\n\ntry:\n    stream = litellm.completion(model=m, messages=msgs, stream=True)\n    for chunk in stream:\n        process(chunk)\nexcept OpenAIError as e:\n    if 'Original Response' in e.message:\n        if '<html' in e.message.lower():\n            alert_ops('proxy error page returned — check api_base path and upstream health')\n        raise","preventionTips":["Assert content-type is text/event-stream in endpoint smoke tests","Keep the api_base path convention in a single config constant","Alert on HTML bodies — they always indicate path/proxy misconfiguration, not model errors","Include the Original Response section in error reports; it is the raw upstream diagnostic"],"tags":["streaming","reverse-proxy","upstream-error","error-body"],"backgroundTag":"streaming-request-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}