BerriAI/litellm · error · Timeout
APITimeoutError - Request timed out. Error_str: {error_str}
Error message
APITimeoutError - Request timed out. Error_str: {error_str} What it means
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.
Source
Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:2256
pass
################################################################################
# End of Common Extra information Needed for all providers
################################################################################
################################################################################
#################### Start of Provider Exception mapping ####################
################################################################################
if (
"Request Timeout Error" in error_str
or "Request timed out" in error_str
or "Timed out generating response" in error_str
or "The read operation timed out" in error_str
):
exception_mapping_worked = True
raise Timeout(
message=f"APITimeoutError - Request timed out. Error_str: {error_str}",
model=model,
llm_provider=custom_llm_provider,
litellm_debug_info=extra_information,
)
if (
custom_llm_provider == "litellm_proxy"
): # handle special case where calling litellm proxy + exception str contains error message
extract_and_raise_litellm_exception(
response=getattr(original_exception, "response", None),
error_str=error_str,
model=model,
custom_llm_provider=custom_llm_provider,
)
if (
custom_llm_provider == "openai"
or custom_llm_provider == "text-completion-openai"View on GitHub (pinned to 6c2dcb801b)
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.
Example fix
# before resp = litellm.completion(model='ollama/llama3', messages=msgs) # after resp = litellm.completion(model='ollama/llama3', messages=msgs, timeout=600, stream=True)
Defensive patterns
Strategy: retry
Try / catch
try {
await litellm.completion(...);
} catch (e) {
if (e instanceof litellm.Timeout) { /* raise per-call timeout or reduce workload */ }
} Prevention
- Set timeout proportional to expected generation length.
- Enable streaming for long outputs.
- Catch litellm.Timeout specifically and retry idempotent requests.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- TogetherAIException - {error_str}
- Braintrust API error: {e.response.text}
- Failed to connect to Braintrust API: {str(e)}
- api_base is required for Pydantic AI agents
- Task {task_id} did not complete within {max_attempts * poll_
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/2b67a513c482dc40.
Report an issue: GitHub.