{"record":{"id":"2b67a513c482dc40","repo":"BerriAI/litellm","slug":"apitimeouterror-request-timed-out-error-str-e","errorCode":null,"errorMessage":"APITimeoutError - Request timed out. Error_str: {error_str}","messagePattern":"APITimeoutError - Request timed out\\. Error_str: (.+?)","errorType":"exception","errorClass":"Timeout","httpStatus":408,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":2256,"sourceCode":"                pass\n\n            ################################################################################\n            # End of Common Extra information Needed for all providers\n            ################################################################################\n\n            ################################################################################\n            #################### Start of Provider Exception mapping ####################\n            ################################################################################\n\n            if (\n                \"Request Timeout Error\" in error_str\n                or \"Request timed out\" in error_str\n                or \"Timed out generating response\" in error_str\n                or \"The read operation timed out\" in error_str\n            ):\n                exception_mapping_worked = True\n\n                raise Timeout(\n                    message=f\"APITimeoutError - Request timed out. Error_str: {error_str}\",\n                    model=model,\n                    llm_provider=custom_llm_provider,\n                    litellm_debug_info=extra_information,\n                )\n\n            if (\n                custom_llm_provider == \"litellm_proxy\"\n            ):  # handle special case where calling litellm proxy + exception str contains error message\n                extract_and_raise_litellm_exception(\n                    response=getattr(original_exception, \"response\", None),\n                    error_str=error_str,\n                    model=model,\n                    custom_llm_provider=custom_llm_provider,\n                )\n            if (\n                custom_llm_provider == \"openai\"\n                or custom_llm_provider == \"text-completion-openai\"","sourceCodeStart":2238,"sourceCodeEnd":2274,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/exception_mapping_utils.py#L2238-L2274","documentation":"LiteLLM scans the string of the original exception for phrases like 'Request Timeout Error', 'Request timed out', 'Timed out generating response', or 'The read operation timed out', and re-raises them as a unified Timeout exception. This normalizes client-side and provider-side timeout wording into one type.","triggerScenarios":"Calls where the HTTP client read/connect timeout expires (httpx.ReadTimeout surfaced as 'Request timed out'), or the provider returns a body/timeouts with those exact phrases (e.g. 'Timed out generating response' from streaming backends).","commonSituations":"Default 600s litellm timeout too short for long generations, low per-call timeout passed, slow local inference hardware (Ollama on CPU), or provider under heavy load.","solutions":["Raise the timeout parameter on the call (litellm.completion(..., timeout=300)).","Set a model-specific default timeout via Router/model_list litellm_params.timeout.","Enable streaming so partial results arrive before the deadline.","For local models, use faster hardware/quantization or a smaller model."],"exampleFix":"# before\nresp = litellm.completion(model='ollama/llama3', messages=msgs)\n\n# after\nresp = litellm.completion(model='ollama/llama3', messages=msgs, timeout=600, stream=True)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await litellm.completion(...);\n} catch (e) {\n  if (e instanceof litellm.Timeout) { /* raise per-call timeout or reduce workload */ }\n}","preventionTips":["Set timeout proportional to expected generation length.","Enable streaming for long outputs.","Catch litellm.Timeout specifically and retry idempotent requests."],"tags":["timeout","client-timeout","streaming","retryable"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}