{"record":{"id":"281ada5c60b552bd","repo":"BerriAI/litellm","slug":"cometapi-error","errorCode":null,"errorMessage":"CometAPI Error: {}","messagePattern":"CometAPI Error: (.+?)","errorType":"http","errorClass":"CometAPIException","httpStatus":400,"severity":"error","filePath":"litellm/llms/cometapi/chat/transformation.py","lineNumber":166,"sourceCode":"            json_mode=json_mode,\n        )\n\n\nclass CometAPIChatCompletionStreamingHandler(BaseModelResponseIterator):\n    \"\"\"\n    Handler for CometAPI streaming chat completion responses\n    \"\"\"\n\n    def chunk_parser(self, chunk: dict) -> ModelResponseStream:\n        \"\"\"\n        Parse individual chunks from streaming response\n        \"\"\"\n        try:\n            # Handle error in chunk\n            if \"error\" in chunk:\n                error_chunk: Final = chunk[\"error\"]\n                error_message: Final = \"CometAPI Error: {}\".format(error_chunk.get(\"message\", \"Unknown error\"))\n                raise CometAPIException(\n                    message=error_message,\n                    status_code=error_chunk.get(\"code\", 400),\n                    headers={\"Content-Type\": \"application/json\"},\n                )\n\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\"),","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/cometapi/chat/transformation.py#L148-L184","documentation":"Provider error surfaced inside the CometAPI streaming chunk parser: the SSE chunk payload contains an 'error' object, meaning CometAPI rejected or failed the request mid-stream; the handler wraps the provider's error message (defaulting to 'Unknown error').","triggerScenarios":"Thrown at litellm/llms/cometapi/chat/transformation.py:166 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the error payload appended after 'CometAPI Error:' for the provider's message.","Verify COMETAPI_KEY/COMETAPI_API_KEY is set and the requested model is enabled for your CometAPI account."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}