BerriAI/litellm · error · OobaboogaError

raw_response.text

Error message

raw_response.text

What it means

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.

Source

Thrown at litellm/llms/oobabooga/chat/transformation.py:56

        optional_params: dict,
        litellm_params: dict,
        encoding: Any,
        api_key: str | None = None,
        json_mode: bool | None = None,
    ) -> ModelResponse:
        ## LOGGING
        logging_obj.post_call(
            input=messages,
            api_key=api_key,
            original_response=raw_response.text,
            additional_args={"complete_input_dict": request_data},
        )

        ## RESPONSE OBJECT
        try:
            completion_response: Final = raw_response.json()
        except Exception:
            raise OobaboogaError(message=raw_response.text, status_code=raw_response.status_code)
        if "error" in completion_response:
            raise OobaboogaError(
                message=completion_response["error"],
                status_code=raw_response.status_code,
            )
        else:
            try:
                model_response.choices[0].message.content = completion_response["choices"][0]["message"]["content"]
            except Exception as e:
                raise OobaboogaError(
                    message=str(e),
                    status_code=raw_response.status_code,
                )

        model_response.created = int(time.time())
        model_response.model = model
        usage: Final = Usage(
            prompt_tokens=completion_response["usage"]["prompt_tokens"],

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Check api_base targets the OpenAI-compatible API port (default 5000), not the Gradio UI port (7860).
  2. curl the /v1/chat/completions endpoint directly to see the raw body being returned; the message field of the error shows it verbatim.
  3. If a proxy returns the HTML, fix upstream availability or proxy error handling.

Example fix

# before
litellm.completion(model="oobabooga/m", api_base="http://127.0.0.1:7860", messages=[...])  # Gradio UI port

# after
litellm.completion(model="oobabooga/m", api_base="http://127.0.0.1:5000", messages=[...])  # OpenAI API port
Defensive patterns

Strategy: validation

Validate before calling

import httpx
r = httpx.get(f"{api_base}/v1/models")  # cheap liveness probe
if r.headers.get("content-type", "").startswith("text/html"):
    raise ValueError(f"{api_base} returns HTML — wrong port or proxy in front")

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/793041737f00705f. Report an issue: GitHub.