BerriAI/litellm · error · VertexAIError
Timeout error occurred.
Error message
Timeout error occurred.
What it means
In the async multimodal embedding handler, an httpx.TimeoutException (connect/read/write/pool timeout) is converted into VertexAIError with status 408 and the fixed message 'Timeout error occurred.' The timeout budget comes from the timeout argument (default 300s in the embedding entry point) or the client you inject. The fixed message means the caller cannot tell which phase timed out — only that the request exceeded the budget.
Source
Thrown at litellm/llms/vertex_ai/multimodal_embeddings/embedding_handler.py:177
if timeout is not None:
if isinstance(timeout, float) or isinstance(timeout, int):
timeout = httpx.Timeout(timeout)
_params["timeout"] = timeout
client = get_async_httpx_client(
llm_provider=litellm.LlmProviders.VERTEX_AI,
params={"timeout": timeout},
)
else:
client = client
try:
response: Final = await client.post(api_base, headers=headers, json=data)
response.raise_for_status()
except httpx.HTTPStatusError as err:
error_code: Final = err.response.status_code
raise VertexAIError(status_code=error_code, message=err.response.text)
except httpx.TimeoutException:
raise VertexAIError(status_code=408, message="Timeout error occurred.")
return vertex_multimodal_embedding_handler.transform_embedding_response(
model=model,
raw_response=response,
model_response=model_response,
logging_obj=logging_obj,
api_key=api_key,
request_data=data,
optional_params=optional_params,
litellm_params=litellm_params,
)
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Raise the budget: pass timeout=600 to the aembedding call
- Shrink the workload: split inputs into batches and embed fewer/smaller media items per request
- Retry once with backoff — transient network stalls often clear
- Verify network path to {region}-aiplatform.googleapis.com and any proxy configuration
Example fix
# before
resp = await litellm.aembedding(
model='vertex_ai/multimodalembedding@001',
input=['gs://bucket/long-video.mp4'],
timeout=10, # too small for video
)
# after
resp = await litellm.aembedding(
model='vertex_ai/multimodalembedding@001',
input=['gs://bucket/long-video.mp4'],
timeout=600,
) Defensive patterns
Strategy: retry
Validate before calling
REQUEST_TIMEOUT = 600 # size budget to video/media size before calling assert estimated_seconds(inputs) < REQUEST_TIMEOUT, 'split media into smaller batches'
Try / catch
for attempt in range(3):
try:
resp = await litellm.aembedding(
model='vertex_ai/multimodalembedding@001',
input=inputs,
timeout=600,
)
break
except Exception as e:
if getattr(e, 'status_code', None) == 408 or 'Timeout' in str(e):
await asyncio.sleep(2 ** attempt)
continue
raise Prevention
- Set timeout proportional to media size (videos need minutes, not seconds)
- Batch large inputs instead of sending many media URIs at once
- Retry once on timeout — transient stalls are common
- Monitor egress latency to {region}-aiplatform.googleapis.com
When it happens
Trigger: await litellm.aembedding(model='vertex_ai/multimodalembedding@001', input=[..., 'gs://bucket/huge-video.mp4']) where embedding a large video exceeds the default 300s; passing timeout=5 with sizeable media inputs; slow or throttled egress to {region}-aiplatform.googleapis.com; connection pool starvation under high concurrency.
Common situations: Embedding long videos or many instances in one request; aggressive custom timeouts copied from chat-completion code; corporate proxies adding latency; serverless environments with tight networking.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Timeout error occurred.
- Error fetching prompt version '{prompt_version_id}': {e}
- Error getting file metadata for '{file_path}': {e}
- BedrockException: Timeout Error - {error_str}
- Timeout error occurred.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/af6fb6341ff958d7.
Report an issue: GitHub.