{"record":{"id":"f15508532173b03f","repo":"BerriAI/litellm","slug":"timeout-error-occurred-f15508","errorCode":null,"errorMessage":"Timeout error occurred.","messagePattern":"Timeout error occurred\\.","errorType":"http","errorClass":"BedrockError","httpStatus":408,"severity":"error","filePath":"litellm/llms/bedrock/image_edit/handler.py","lineNumber":119,"sourceCode":"                prompt=prompt,\n                model_response=model_response,\n                client=(client if client is not None and isinstance(client, AsyncHTTPHandler) else None),\n            )\n\n        if client is None or not isinstance(client, HTTPHandler):\n            client = _get_httpx_client()\n        try:\n            response: Final = client.post(\n                url=prepared_request.endpoint_url,\n                headers=prepared_request.prepped.headers,\n                data=prepared_request.body,\n            )\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        ### FORMAT RESPONSE TO OPENAI FORMAT ###\n        model_response = self._transform_response_dict_to_openai_response(\n            model_response=model_response,\n            model=model,\n            logging_obj=logging_obj,\n            prompt=prompt,\n            response=response,\n            data=prepared_request.data,\n        )\n        return model_response\n\n    async def async_image_edit(\n        self,\n        prepared_request: BedrockImageEditPreparedRequest,\n        timeout: float | httpx.Timeout | None,\n        model: str,\n        logging_obj: LitellmLogging,","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/image_edit/handler.py#L101-L137","documentation":"The sync Bedrock image-edit call wraps httpx.TimeoutException into BedrockError(status_code=408, message='Timeout error occurred.'). It fires when the POST to the Bedrock runtime endpoint exceeds the httpx client's configured timeout (default or the timeout param passed to the handler) before any response arrives.","triggerScenarios":"Large image payloads (multi-MB base64 in the signed body) over slow links; Bedrock image generation legitimately taking tens of seconds while the client timeout is lower; congested network or proxy stalls between client and bedrock-runtime.<region>.amazonaws.com.","commonSituations":"Default aggressive timeouts in serverless (e.g. 10-30s) while Nova/Stability edits take 30-60s+; uploading 4K images; VPC NAT bottleneck; retry storms amplifying latency.","solutions":["Raise the timeout for image-edit calls: pass timeout=<seconds> (e.g. 120) to litellm.image_edit / the router.","Shrink images before sending (Nova Canvas accepts bounded resolutions; smaller payloads sign and upload faster).","Retry transient timeouts with backoff — the request is idempotent from the client's view (no side effects besides spend).","Check network path (NAT/proxy) for throttling large request bodies."],"exampleFix":"# before\nresp = litellm.image_edit(model=..., image=img, prompt=...)  # default timeout -> 408\n# after\nresp = litellm.image_edit(model=..., image=img, prompt=..., timeout=120)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.exceptions import BedrockError\n\nfor attempt in range(3):\n    try:\n        resp = litellm.image_edit(model=m, image=img, prompt=p, timeout=120)\n        break\n    except BedrockError as e:\n        if e.status_code != 408 or attempt == 2:\n            raise\n        time.sleep(2 ** attempt)","preventionTips":["Set explicit generous timeouts (>=120s) for image edit calls.","Downscale images before upload to cut transfer time.","Distinguish 408 (timeout) from other BedrockErrors in retry logic."],"tags":["bedrock","image-edit","timeout","network"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}