{"record":{"id":"9fa4f0f3f542ede3","repo":"BerriAI/litellm","slug":"keyerror-e-got-unexpected-response-from-cometa","errorCode":null,"errorMessage":"KeyError: {e}, Got unexpected response from CometAPI: {chunk}","messagePattern":"KeyError: (.+?), Got unexpected response from CometAPI: (.+?)","errorType":"exception","errorClass":"CometAPIException","httpStatus":400,"severity":"error","filePath":"litellm/llms/cometapi/chat/transformation.py","lineNumber":189,"sourceCode":"\n            # Process choices\n            new_choices: Final = []\n            for choice in chunk[\"choices\"]:\n                # Handle reasoning content if present\n                if \"delta\" in choice and \"reasoning\" in choice[\"delta\"]:\n                    choice[\"delta\"][\"reasoning_content\"] = choice[\"delta\"].get(\"reasoning\")\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 CometAPIException(\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":171,"sourceCodeEnd":196,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/cometapi/chat/transformation.py#L171-L196","documentation":"Error \"KeyError: {e}, Got unexpected response from CometAPI: {chunk}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/cometapi/chat/transformation.py:189 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The CometAPI response chunk had an unexpected shape; check the provider response."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}