BerriAI/litellm · error · OobaboogaError

completion_response["error"]

Error message

completion_response["error"]

What it means

After successfully parsing the oobabooga chat response as JSON, the transformation checks for an 'error' key. If the JSON body carries an error payload (even with HTTP 200), an OobaboogaError is raised with that error text and the upstream status code. This is a pass-through of an in-body error from text-generation-webui.

Source

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

        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"],
            completion_tokens=completion_response["usage"]["completion_tokens"],
            total_tokens=completion_response["usage"]["total_tokens"],

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Read the error message — it is verbatim from the webui and identifies the failing parameter or condition.
  2. Reproduce with curl to see the full body; simplify generation parameters (stop, max_tokens) to isolate the trigger.
  3. Update text-generation-webui / its OpenAI extension if error reporting looks malformed.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    resp = litellm.completion(model="oobabooga/m", messages=msgs, api_base=base)
except Exception as e:
    if getattr(e, "status_code", None) == 400 and "error" in str(e):
        # in-body error from the webui: message is verbatim
        log_and_alert(str(e))

Prevention

When it happens

Trigger: The webui returns 200 with {"error": {"message": ...}} or {"error": "..."} — typical for internal generation failures, invalid parameters accepted at HTTP level, or generation stopped by content filters.

Common situations: Server-side generation aborts (max_new_tokens misconfigured, model unloaded mid-request), or API extension versions that report errors in-body rather than via status codes.

Related errors


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