{"record":{"id":"51afdcfdc74cf26d","repo":"BerriAI/litellm","slug":"timeout-error-occurred-51afdc","errorCode":null,"errorMessage":"Timeout error occurred.","messagePattern":"Timeout error occurred\\.","errorType":"http","errorClass":"BedrockError","httpStatus":408,"severity":"error","filePath":"litellm/llms/bedrock/embed/embedding.py","lineNumber":117,"sourceCode":"        data: dict,\n    ) -> dict:\n        if client is None or not isinstance(client, HTTPHandler):\n            _params: Final = {}\n            if timeout is not None:\n                if isinstance(timeout, float) or isinstance(timeout, int):\n                    timeout = httpx.Timeout(timeout)\n                _params[\"timeout\"] = timeout\n            client = _get_httpx_client(_params)\n        else:\n            client = client\n        try:\n            response: Final = client.post(url=api_base, headers=headers, data=json.dumps(data))\n            response.raise_for_status()\n        except httpx.HTTPStatusError as err:\n            error_code: Final = err.response.status_code\n            raise BedrockError(status_code=error_code, message=err.response.text)\n        except httpx.TimeoutException:\n            raise BedrockError(status_code=408, message=\"Timeout error occurred.\")\n\n        return response.json()\n\n    async def _make_async_call(\n        self,\n        client: AsyncHTTPHandler | None,\n        timeout: float | httpx.Timeout | None,\n        api_base: str,\n        headers: dict,\n        data: dict,\n    ) -> dict:\n        if client is None or not isinstance(client, AsyncHTTPHandler):\n            _params: Final = {}\n            if timeout is not None:\n                if isinstance(timeout, float) or isinstance(timeout, int):\n                    timeout = httpx.Timeout(timeout)\n                _params[\"timeout\"] = timeout\n            client = get_async_httpx_client(params=_params, llm_provider=litellm.LlmProviders.BEDROCK)","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/embed/embedding.py#L99-L135","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nresp = litellm.embedding(model=\"bedrock/cohere.embed-english-v3\", input=big_batch, timeout=5)\n\n# after\nresp = litellm.embedding(model=\"bedrock/cohere.embed-english-v3\", input=big_batch, timeout=600)\n# or chunk the input:\nfor chunk in chunks(big_batch, 16):\n    resp = litellm.embedding(model=\"bedrock/cohere.embed-english-v3\", input=chunk)","handlingStrategy":"retry","validationCode":"from litellm import embedding\ntimeout = 600\nassert timeout is None or timeout >= 30, \"bedrock embedding timeout too low for batch input\"","typeGuard":"def is_bedrock_timeout_error(exc: Exception) -> bool:\n    return getattr(exc, \"status_code\", None) == 408 and type(exc).__name__ == \"BedrockError\"","tryCatchPattern":"from litellm.exceptions import BedrockError\nfor attempt in range(3):\n    try:\n        resp = litellm.embedding(model=model, input=chunk)\n        break\n    except BedrockError as e:\n        if e.status_code != 408 or attempt == 2:\n            raise\n        time.sleep(2 ** attempt)","preventionTips":["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."],"tags":["bedrock","embedding","timeout","network","aws"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}