{"record":{"id":"f1a3b6a185c84669","repo":"BerriAI/litellm","slug":"error-get-message","errorCode":null,"errorMessage":"error.get(\"message\")","messagePattern":"error\\.get\\(\"message\"\\)","errorType":"http","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/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/groq/chat/transformation.py#L334-L363","documentation":"This is the error-forwarding site in GroqChatCompletionStreamingHandler.chunk_parser: when a streamed SSE chunk from Groq contains a top-level \"error\" object, LiteLLM re-raises it as an OpenAIError carrying the upstream status code, message, and raw body. So the message you see is Groq's own error text (error.get(\"message\")), surfaced mid-stream by LiteLLM — not a bug in the line itself.","triggerScenarios":"Streaming a Groq completion (stream=True) that fails after the stream opens: model name typo/undeployed model, rate limits, overloaded Groq capacity, or an invalid/revoked GROQ_API_KEY — Groq emits {\"error\": {\"code\": ..., \"message\": ...}} as a chunk and this handler raises.","commonSituations":"Using model='groq/llama-3.x-...' with a model id that was deprecated or renamed; hitting Groq free-tier rate limits during bursts; expired API key that only fails at stream time; transient 5xx/overloads on Groq's side.","solutions":["Read the surfaced message/code: 401/403 → fix GROQ_API_KEY; 404 → fix the model name against Groq's current model list; 429 → slow down, add rate limiting, or upgrade tier; 5xx/overloaded → retry with backoff.","For transient errors, retry the streaming call with exponential backoff (litellm supports num_retries, or wrap your loop).","Guard upstream: validate model ids when Groq deprecates models, and pin versions you have tested.","If errors persist with a valid key and model, check Groq status page and Groq console for outage/quota issues."],"exampleFix":"# before\nresponse = litellm.completion(model='groq/llama3-70b-8192', messages=msgs, stream=True)\nfor chunk in response: ...  # raises OpenAIError mid-stream on Groq-side error\n\n# after\ntry:\n    response = litellm.completion(\n        model='groq/llama-3.3-70b-versatile', messages=msgs, stream=True, num_retries=3\n    )\n    for chunk in response:\n        ...\nexcept litellm.exceptions.OpenAIError as e:\n    # inspect e.status_code: 401 fix key, 404 fix model, 429 back off, 5xx retry later\n    raise\n","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    stream = litellm.completion(model=\"groq/...\", messages=msgs, stream=True, num_retries=3)\n    for chunk in stream:\n        ...\nexcept litellm.exceptions.OpenAIError as e:\n    code = getattr(e, \"status_code\", None)\n    if code == 404:\n        raise RuntimeError(\"Bad groq model id\") from e\n    if code == 429 or code >= 500:\n        backoff_and_retry()  # transient\n    raise","preventionTips":["Treat any mid-stream OpenAIError from groq as upstream Groq status — branch on status_code, do not parse it as a client bug.","Keep model ids pinned to Groq's current model list and update them when Groq deprecates.","Use num_retries and rate limiting around groq calls to absorb 429/5xx without manual loops."],"tags":["groq","streaming","error-forwarding","rate-limit","api-key"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}