BerriAI/litellm · error · OVHCloudException
KeyError: {e}, Got unexpected response from CometAPI: {chunk
Error message
KeyError: {e}, Got unexpected response from CometAPI: {chunk} What it means
While constructing the ModelResponseStream from an OVHCloud SSE chunk, a required key ('id', 'created', 'model', or 'choices') is missing and the resulting KeyError is converted into an OVHCloudException with status 400. The message text says 'CometAPI' - this is a copy-paste artifact in litellm; the failing provider is OVHCloud, and the offending chunk is embedded in the message for diagnosis.
Source
Thrown at litellm/llms/ovhcloud/chat/transformation.py:111
# `reasoning_content` is replaced by `reasoning`.
# Normalise to `reasoning_content` so downstream consumers
# see a consistent key during the transition window.
reasoning_new = delta.get("reasoning")
reasoning_legacy = delta.get("reasoning_content")
if reasoning_new is not None and reasoning_legacy is None:
delta["reasoning_content"] = reasoning_new
new_choices.append(choice)
return ModelResponseStream(
id=chunk["id"],
object="chat.completion.chunk",
created=chunk["created"],
usage=chunk.get("usage"),
model=chunk["model"],
choices=new_choices,
)
except KeyError as e:
raise OVHCloudException(
message=f"KeyError: {e}, Got unexpected response from CometAPI: {chunk}",
status_code=400,
headers={"Content-Type": "application/json"},
)
except Exception as e:
raise e
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Log the exception message - it embeds the exact chunk that failed, revealing which key was missing
- Upgrade litellm; parser gaps for non-standard chunks are usually patched upstream
- File a litellm issue - the 'CometAPI' wording confirms the bug lives in the OVHCloud chunk parser
- As a workaround, retry non-streaming so the full payload arrives as one JSON body
Defensive patterns
Strategy: fallback
Try / catch
Catch OVHCloudException; when the message contains 'KeyError', fall back to a non-streaming retry for that request so the full JSON body is parsed in one piece, and report the offending chunk (embedded in the message) upstream.
Prevention
- Keep a non-streaming fallback path for every streaming integration
- Record chunks that trigger parser KeyErrors to detect provider framing changes early
- Upgrade litellm when OVH stream framing changes are patched
When it happens
Trigger: OVHCloud sends a non-standard chunk in the stream: usage-only final chunks lacking id/model, keep-alive or heartbeat objects, or any SSE event that is not a full chat.completion.chunk dict with all four required keys.
Common situations: OVH changes stream framing (e.g., appending usage chunks without standard fields); proxies injecting heartbeat lines into the SSE stream; schema drift after OVH API updates.
Related errors
- OVHCloud Error: {}
- Chat provider: Empty parsed_chunk
- Chat provider: Invalid chunk type {type(parsed_chunk)}
- Chat provider: Invalid function argument delta {parsed_chunk
- Error in response object format
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/ac80b4361658142e.
Report an issue: GitHub.