{"record":{"id":"f27e2d587614578d","repo":"BerriAI/litellm","slug":"message-metadata-user-id","errorCode":null,"errorMessage":"Message: {}, Metadata: {}, User ID: {}","messagePattern":"Message: (.+?), Metadata: (.+?), User ID: (.+?)","errorType":"http","errorClass":"OpenRouterException","httpStatus":null,"severity":"error","filePath":"litellm/llms/openrouter/chat/transformation.py","lineNumber":263,"sourceCode":"        )\n\n\nclass OpenRouterChatCompletionStreamingHandler(BaseModelResponseIterator):\n    def chunk_parser(self, chunk: dict) -> ModelResponseStream:\n        try:\n            ## HANDLE ERROR IN CHUNK ##\n            if \"error\" in chunk:\n                error_chunk: Final = chunk[\"error\"]\n                error_message: Final = OpenRouterErrorMessage(\n                    message=\"Message: {}, Metadata: {}, User ID: {}\".format(\n                        error_chunk[\"message\"],\n                        error_chunk.get(\"metadata\", {}),\n                        error_chunk.get(\"user_id\", \"\"),\n                    ),\n                    code=error_chunk[\"code\"],\n                    metadata=error_chunk.get(\"metadata\", {}),\n                )\n                raise OpenRouterException(\n                    message=error_message[\"message\"],\n                    status_code=error_message[\"code\"],\n                    headers=error_message[\"metadata\"].get(\"headers\", {}),\n                )\n\n            new_choices: Final = []\n            for choice in chunk[\"choices\"]:\n                choice[\"delta\"][\"reasoning_content\"] = choice[\"delta\"].get(\"reasoning\")\n                new_choices.append(choice)\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:","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/openrouter/chat/transformation.py#L245-L281","documentation":"Streaming error-chunk formatter in the OpenRouter handler: an in-stream 'error' object arrived (OpenRouter reports mid-stream failures this way), and this message template packs the error's message, metadata, and user_id into the raised exception text.","triggerScenarios":"Thrown at litellm/llms/openrouter/chat/transformation.py:263 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the OpenRouter error message/metadata in the exception; common causes are insufficient credits, invalid model slug, or moderation refusal."],"exampleFix":null,"handlingStrategy":"type-guard","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-14T05:17:10.506Z"}