BerriAI/litellm · error · OobaboogaError
str(e)
Error message
str(e)
What it means
After the error checks, the oobabooga transformation copies `completion_response['choices'][0]['message']['content']` into the model response. Any shape mismatch (missing 'choices', empty list, missing 'message'/'content') raises an exception whose str(e) becomes the OobaboogaError message with the upstream status code.
Source
Thrown at litellm/llms/oobabooga/chat/transformation.py:66
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"],
)
setattr(model_response, "usage", usage)
return model_response
def validate_environment(
self,
headers: dict,
model: str,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Inspect the exception message (it shows the KeyError/TypeError path) and the logged original_response to see the actual JSON shape.
- Update text-generation-webui so its OpenAI extension returns proper chat.completion JSON, or pin LiteLLM to a version matching your webui version.
- Ensure api_base points at /v1-compatible routes and a chat-capable model is loaded.
Defensive patterns
Strategy: validation
Try / catch
try:
resp = litellm.completion(model="oobabooga/m", messages=msgs, api_base=base)
except Exception as e:
if "choices" in str(e) or "message" in str(e):
# response shape mismatch: dump server response for diagnosis
dump_raw_response(base) Prevention
- Pin compatible webui + LiteLLM versions
- Return to curl to compare actual vs expected response shape
- Never assume non-OpenAI servers emit exact OpenAI chat JSON
When it happens
Trigger: The webui returns JSON without a choices array (e.g. a bare error object without an 'error' key, or a legacy response format), or with an empty choices list, or a completion-style response ({'text': ...}) served on the chat endpoint.
Common situations: Version mismatch between text-generation-webui's OpenAI extension and LiteLLM's expected OpenAI chat shape; pointing the chat handler at a legacy/non-chat endpoint; or server stubs returning truncated responses in tests.
Related errors
- No image URL in BFL result
- No polling_url in BFL response
- OCI embed response does not match expected schema: {e}
- raw_response.text
- completion_response["error"]
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/bae12149f9646f11.
Report an issue: GitHub.