{"record":{"id":"793041737f00705f","repo":"BerriAI/litellm","slug":"raw-response-text-793041","errorCode":null,"errorMessage":"raw_response.text","messagePattern":"raw_response\\.text","errorType":"exception","errorClass":"OobaboogaError","httpStatus":null,"severity":"error","filePath":"litellm/llms/oobabooga/chat/transformation.py","lineNumber":56,"sourceCode":"        optional_params: dict,\n        litellm_params: dict,\n        encoding: Any,\n        api_key: str | None = None,\n        json_mode: bool | None = None,\n    ) -> ModelResponse:\n        ## LOGGING\n        logging_obj.post_call(\n            input=messages,\n            api_key=api_key,\n            original_response=raw_response.text,\n            additional_args={\"complete_input_dict\": request_data},\n        )\n\n        ## RESPONSE OBJECT\n        try:\n            completion_response: Final = raw_response.json()\n        except Exception:\n            raise OobaboogaError(message=raw_response.text, status_code=raw_response.status_code)\n        if \"error\" in completion_response:\n            raise OobaboogaError(\n                message=completion_response[\"error\"],\n                status_code=raw_response.status_code,\n            )\n        else:\n            try:\n                model_response.choices[0].message.content = completion_response[\"choices\"][0][\"message\"][\"content\"]\n            except Exception as e:\n                raise OobaboogaError(\n                    message=str(e),\n                    status_code=raw_response.status_code,\n                )\n\n        model_response.created = int(time.time())\n        model_response.model = model\n        usage: Final = Usage(\n            prompt_tokens=completion_response[\"usage\"][\"prompt_tokens\"],","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oobabooga/chat/transformation.py#L38-L74","documentation":"In the oobabooga chat transformation, `raw_response.json()` is wrapped in try/except. If the body is not valid JSON (non-JSON error page, empty body, HTML), an OobaboogaError is raised whose message is the raw response text and whose status code is the upstream status.","triggerScenarios":"The webui returns an HTML error page (500 traceback page, auth page), an empty 502 from a reverse proxy, or plain-text error — anything served with Content-Type that still reaches this handler as non-JSON.","commonSituations":"Reverse proxies (nginx/traefik) returning HTML error pages when the webui is down; the webui crashing mid-request; pointing api_base at the Gradio UI port instead of the OpenAI API port (5000 vs 7860).","solutions":["Check api_base targets the OpenAI-compatible API port (default 5000), not the Gradio UI port (7860).","curl the /v1/chat/completions endpoint directly to see the raw body being returned; the message field of the error shows it verbatim.","If a proxy returns the HTML, fix upstream availability or proxy error handling."],"exampleFix":"# before\nlitellm.completion(model=\"oobabooga/m\", api_base=\"http://127.0.0.1:7860\", messages=[...])  # Gradio UI port\n\n# after\nlitellm.completion(model=\"oobabooga/m\", api_base=\"http://127.0.0.1:5000\", messages=[...])  # OpenAI API port","handlingStrategy":"validation","validationCode":"import httpx\nr = httpx.get(f\"{api_base}/v1/models\")  # cheap liveness probe\nif r.headers.get(\"content-type\", \"\").startswith(\"text/html\"):\n    raise ValueError(f\"{api_base} returns HTML — wrong port or proxy in front\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Target the OpenAI API port (5000), not the Gradio UI port (7860)","Probe endpoints for JSON content-type at startup","Don't put HTML-returning error pages in front of API routes"],"tags":["oobabooga","json","response-parsing","configuration"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}