{"record":{"id":"c486c1e968ba6580","repo":"BerriAI/litellm","slug":"message","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"exception","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"litellm/llms/groq/chat/transformation.py","lineNumber":352,"sourceCode":"            return ()\n\n    def _map_groq_service_tier(self, original_service_tier: str | None) -> Literal[\"auto\", \"default\", \"flex\"]:\n        \"\"\"\n        Ensure groq service tier is OpenAI compatible.\n        \"\"\"\n        if original_service_tier is None:\n            return \"auto\"\n        if original_service_tier not in [\"auto\", \"default\", \"flex\"]:\n            return \"auto\"\n\n        return cast(Literal[\"auto\", \"default\", \"flex\"], original_service_tier)\n\n\nclass GroqChatCompletionStreamingHandler(OpenAIChatCompletionStreamingHandler):\n    def chunk_parser(self, chunk: dict) -> ModelResponseStream:\n        error: Final = chunk.get(\"error\")\n        if error:\n            raise OpenAIError(status_code=error.get(\"code\"), message=error.get(\"message\"), body=error)\n\n        # Map Groq's 'reasoning' field to LiteLLM's 'reasoning_content' field\n        # Groq returns delta.reasoning, but LiteLLM expects delta.reasoning_content\n        choices: Final = chunk.get(\"choices\", [])\n        for choice in choices:\n            delta = choice.get(\"delta\", {})\n            if \"reasoning\" in delta:\n                delta[\"reasoning_content\"] = delta.pop(\"reasoning\")\n\n        return super().chunk_parser(chunk)\n","sourceCodeStart":334,"sourceCodeEnd":363,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/groq/chat/transformation.py#L334-L363","documentation":"Raised by LiteLLM's Groq streaming chunk parser when a streamed SSE chunk from Groq contains an 'error' object instead of completion data. Groq reports some failures (rate limits, model overloaded, invalid arguments) mid-stream after the HTTP 200 connection is already open; LiteLLM surfaces them by raising OpenAIError with the chunk's code, message, and body. The '{message}' placeholder is filled with Groq's own error text, so the wording varies by failure mode.","triggerScenarios":"Calling litellm.completion(model='groq/<model>', ..., stream=True) and iterating chunks when Groq injects {'error': {...}} into the stream: rate limit exceeded, model overloaded or deprecated, context length exceeded, or an invalid model id that Groq only rejects after streaming begins. The error surfaces while consuming the chunk generator, not at call time.","commonSituations":"Hitting Groq free-tier RPM/TPM limits during batch jobs; using a deprecated/renamed Groq model id; sending an oversized prompt; transient Groq incidents. Developers are often confused because the request initially succeeds (HTTP 200) and tokens stream before the exception fires mid-iteration.","solutions":["Read the raised OpenAIError's message and status_code first — it is Groq's own error text (rate limit, overloaded, etc.) and identifies the cause","If rate limited: slow down the request rate, add exponential backoff, or raise your Groq rate limits","Verify the model id against Groq's current model list — deprecated models are removed and only fail at request time","Reduce prompt size if the message mentions token/context limits","Check Groq's status page if the failures are transient 'overloaded' errors"],"exampleFix":"// before\nresponse = litellm.completion(\n    model=\"groq/llama-3.3-70b-versatile\", messages=msgs, stream=True\n)\nfor chunk in response:\n    print(chunk.choices[0].delta.content)\n\n// after\nfrom litellm.llms.openai.common_utils import OpenAIError\n\ntry:\n    response = litellm.completion(\n        model=\"groq/llama-3.3-70b-versatile\", messages=msgs, stream=True\n    )\n    for chunk in response:\n        print(chunk.choices[0].delta.content)\nexcept OpenAIError as e:\n    print(\"Groq stream failed:\", e.status_code, e.message)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Wrap the whole chunk-iteration loop, not just the completion() call — the error is raised while consuming the stream generator. Catch OpenAIError (or litellm's LiteLLMError base) and branch on status_code: 429 → exponential backoff and re-issue the full request; 404/400 → stop and fix model id/params; overloaded/5xx → retry with jitter or route to a fallback model via litellm Router. Accumulate already-streamed text so partial output is not lost.","preventionTips":["Keep a validated list of current Groq model ids and check against it before streaming","Apply client-side rate limiting below your Groq quota instead of discovering limits via stream errors","Use litellm Router with fallbacks and retry_policy so mid-stream provider errors trigger automatic failover","Log status_code + message from OpenAIError — they carry Groq's exact reason"],"tags":["groq","streaming","provider-error","rate-limit","litellm"],"backgroundTag":"provider-stream-error","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}