{"record":{"id":"ac80b4361658142e","repo":"BerriAI/litellm","slug":"keyerror-e-got-unexpected-response-from-cometa-ac80b4","errorCode":null,"errorMessage":"KeyError: {e}, Got unexpected response from CometAPI: {chunk}","messagePattern":"KeyError: (.+?), Got unexpected response from CometAPI: (.+?)","errorType":"http","errorClass":"OVHCloudException","httpStatus":400,"severity":"error","filePath":"litellm/llms/ovhcloud/chat/transformation.py","lineNumber":111,"sourceCode":"                    # `reasoning_content` is replaced by `reasoning`.\n                    # Normalise to `reasoning_content` so downstream consumers\n                    # see a consistent key during the transition window.\n                    reasoning_new = delta.get(\"reasoning\")\n                    reasoning_legacy = delta.get(\"reasoning_content\")\n                    if reasoning_new is not None and reasoning_legacy is None:\n                        delta[\"reasoning_content\"] = reasoning_new\n                new_choices.append(choice)\n\n            return ModelResponseStream(\n                id=chunk[\"id\"],\n                object=\"chat.completion.chunk\",\n                created=chunk[\"created\"],\n                usage=chunk.get(\"usage\"),\n                model=chunk[\"model\"],\n                choices=new_choices,\n            )\n        except KeyError as e:\n            raise OVHCloudException(\n                message=f\"KeyError: {e}, Got unexpected response from CometAPI: {chunk}\",\n                status_code=400,\n                headers={\"Content-Type\": \"application/json\"},\n            )\n        except Exception as e:\n            raise e\n","sourceCodeStart":93,"sourceCodeEnd":118,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/ovhcloud/chat/transformation.py#L93-L118","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"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.","preventionTips":["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"],"tags":["ovhcloud","streaming","sse","key-error","parser-bug","litellm"],"backgroundTag":"response-schema-mismatch","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}