{"record":{"id":"70f3f2c78912b649","repo":"BerriAI/litellm","slug":"message-70f3f2","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"http","errorClass":"OpenAIError","httpStatus":null,"severity":"error","filePath":"litellm/llms/openai/openai.py","lineNumber":947,"sourceCode":"\n                return final_response_obj\n            except openai.UnprocessableEntityError as e:\n                ## check if body contains unprocessable params - related issue https://github.com/BerriAI/litellm/issues/4800\n                if litellm.drop_params is True or drop_params is True:\n                    data = drop_params_from_unprocessable_entity_error(e, data)\n                else:\n                    raise e\n                # e.message\n            except Exception as e:\n                exception_response = getattr(e, \"response\", None)\n                status_code = getattr(e, \"status_code\", 500)\n                exception_body = getattr(e, \"body\", None)\n                error_headers = getattr(e, \"headers\", None)\n                if error_headers is None and exception_response:\n                    error_headers = getattr(exception_response, \"headers\", None)\n                message = getattr(e, \"message\", str(e))\n\n                raise OpenAIError(\n                    status_code=status_code,\n                    message=message,\n                    headers=error_headers,\n                    body=exception_body,\n                )\n\n    def streaming(\n        self,\n        logging_obj,\n        timeout: float | httpx.Timeout,\n        data: dict,\n        model: str,\n        api_key: str | None = None,\n        api_base: str | None = None,\n        api_version: str | None = None,\n        organization: str | None = None,\n        client=None,\n        max_retries=None,","sourceCodeStart":929,"sourceCodeEnd":965,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/openai/openai.py#L929-L965","documentation":"Final catch-all of the async acompletion flow (litellm/llms/openai/openai.py:947). Mirrors the sync wrapper: exceptions that are not OpenAIError are converted into one, carrying the upstream status_code (default 500), headers (taken from e.headers, falling back to e.response.headers), body, and a message read from e.message or str(e). The wrapper exists because exceptions raised inside coroutines must be normalized before they cross back into litellm's plumbing.","triggerScenarios":"Async completions failing upstream: 400 context_length_exceeded, 429 rate limit, 401 auth, provider 5xx; asyncio/httpx transport errors surfaced as synthetic 500s carrying the transport message.","commonSituations":"Async fan-out workers tripping rate limits; expired keys in long-lived async clients; prompts exceeding the model context window; provider regional incidents returning 5xx.","solutions":["Inspect e.status_code and e.message to classify: auth vs rate-limit vs context-window vs 5xx","For context-length errors, trim messages or move to a larger-context model","Configure num_retries and litellm.Router fallbacks for 429/5xx","For auth errors rotate the key — retrying will not help"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"import asyncio\nfrom litellm.llms.openai.common_utils import OpenAIError\n\nasync def completion_with_backoff(model, msgs, attempts=3):\n    for i in range(attempts):\n        try:\n            return await litellm.acompletion(model=model, messages=msgs)\n        except OpenAIError as e:\n            if e.status_code == 429 and i < attempts - 1:\n                await asyncio.sleep(2 ** i)\n                continue\n            if e.status_code >= 500 and i < attempts - 1:\n                await asyncio.sleep(1)\n                continue\n            raise","preventionTips":["Check prompt token counts before sending to avoid 400 context_length_exceeded","Use asyncio-friendly exponential backoff; never sleep synchronously in event loops","Configure Router allowed_fails and fallbacks so 429/5xx failover is automatic","Rotate keys on 401 immediately — retries amplify outage duration"],"tags":["error-wrapping","upstream-error","async","rate-limit"],"backgroundTag":"chat-completion-request-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}