BerriAI/litellm · error · BedrockError
Timeout error occurred.
Error message
Timeout error occurred.
What it means
Raised by BedrockEmbedding's sync HTTP path when the httpx client times out calling the Bedrock runtime endpoint. LiteLLM catches httpx.TimeoutException and re-raises it as BedrockError with HTTP status 408 so callers get a provider-uniform error. It does not retry internally; the exception escapes to the embedding caller.
Source
Thrown at litellm/llms/bedrock/embed/embedding.py:117
data: dict,
) -> dict:
if client is None or not isinstance(client, HTTPHandler):
_params: Final = {}
if timeout is not None:
if isinstance(timeout, float) or isinstance(timeout, int):
timeout = httpx.Timeout(timeout)
_params["timeout"] = timeout
client = _get_httpx_client(_params)
else:
client = client
try:
response: Final = client.post(url=api_base, headers=headers, data=json.dumps(data))
response.raise_for_status()
except httpx.HTTPStatusError as err:
error_code: Final = err.response.status_code
raise BedrockError(status_code=error_code, message=err.response.text)
except httpx.TimeoutException:
raise BedrockError(status_code=408, message="Timeout error occurred.")
return response.json()
async def _make_async_call(
self,
client: AsyncHTTPHandler | None,
timeout: float | httpx.Timeout | None,
api_base: str,
headers: dict,
data: dict,
) -> dict:
if client is None or not isinstance(client, AsyncHTTPHandler):
_params: Final = {}
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(params=_params, llm_provider=litellm.LlmProviders.BEDROCK)View on GitHub (pinned to 6c2dcb801b)
Solutions
- Increase or remove the `timeout` value passed to litellm.embedding() (e.g. timeout=600 or leave default).
- Reduce the size of the `input` list so each POST completes faster.
- Verify network latency/egress to the target aws_region_name; use a region closer to the workload.
- Wrap calls in retry logic that catches BedrockError with status_code == 408 and retries with backoff.
Example fix
# before
resp = litellm.embedding(model="bedrock/cohere.embed-english-v3", input=big_batch, timeout=5)
# after
resp = litellm.embedding(model="bedrock/cohere.embed-english-v3", input=big_batch, timeout=600)
# or chunk the input:
for chunk in chunks(big_batch, 16):
resp = litellm.embedding(model="bedrock/cohere.embed-english-v3", input=chunk) Defensive patterns
Strategy: retry
Validate before calling
from litellm import embedding timeout = 600 assert timeout is None or timeout >= 30, "bedrock embedding timeout too low for batch input"
Type guard
def is_bedrock_timeout_error(exc: Exception) -> bool:
return getattr(exc, "status_code", None) == 408 and type(exc).__name__ == "BedrockError" Try / catch
from litellm.exceptions import BedrockError
for attempt in range(3):
try:
resp = litellm.embedding(model=model, input=chunk)
break
except BedrockError as e:
if e.status_code != 408 or attempt == 2:
raise
time.sleep(2 ** attempt) Prevention
- Size the timeout to the batch: ~1s per 10 inputs plus network headroom.
- Chunk embedding inputs to 10-16 items per call.
- Monitor p99 embedding latency and alert before it approaches the configured timeout.
When it happens
Trigger: Calling litellm.embedding() with a bedrock/* embedding model where the POST to https://bedrock-runtime.<region>.amazonaws.com exceeds the configured (or default 600s) request timeout, or when a small `timeout` value was passed via optional_params; large batch embedding inputs also trigger it.
Common situations: Passing timeout= in optional_params that is too low for big embedding batches; slow network path to the AWS region (cross-region calls, VPN); Bedrock runtime throttling that stalls the connection instead of returning a 429.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- BedrockException: Timeout Error - {error_str}
- Missing boto3 to call bedrock. Run 'pip install boto3'.
- {err.response.text}
- Timeout error occurred.
- Model needs to be set for bedrock
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/51afdcfdc74cf26d.
Report an issue: GitHub.