{"record":{"id":"eba596ec28b840ec","repo":"BerriAI/litellm","slug":"timeout-error-occurred-eba596","errorCode":null,"errorMessage":"Timeout error occurred.","messagePattern":"Timeout error occurred\\.","errorType":"http","errorClass":"BedrockError","httpStatus":408,"severity":"error","filePath":"litellm/llms/bedrock/image_generation/image_handler.py","lineNumber":124,"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        ### 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_generation(\n        self,\n        prepared_request: BedrockImagePreparedRequest,\n        timeout: float | httpx.Timeout | None,\n        model: str,\n        logging_obj: LitellmLogging,\n        prompt: str,","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/image_generation/image_handler.py#L106-L142","documentation":"The synchronous Bedrock image-generation request exceeded the configured httpx timeout and httpx.TimeoutException was raised; litellm maps it to BedrockError with status_code=408 and the fixed message 'Timeout error occurred.'. Image generation on Bedrock commonly takes tens of seconds, so the default timeout is frequently too short.","triggerScenarios":"litellm.image_generation(..., timeout=N) or the default client timeout being smaller than the actual generation time; slow models (e.g. stability.stable-diffusion-xl with many steps) on loaded endpoints.","commonSituations":"Using the default timeout for high-resolution/multi-image jobs, network bottlenecks, oversized prompts, or proxy-side latency.","solutions":["Pass a larger timeout explicitly: litellm.image_generation(..., timeout=300).","Reduce output cost: fewer images (numberOfImages=1), smaller width/height, fewer inference steps.","Retry once on timeout — the request is idempotent from the client's perspective.","If persistent, check network egress/proxy latency to the bedrock-runtime endpoint."],"exampleFix":"# before\nresp = litellm.image_generation(model=\"bedrock/stability.stable-image-core-1:0\", prompt=p)\n\n# after\nresp = litellm.image_generation(model=\"bedrock/stability.stable-image-core-1:0\", prompt=p, timeout=300)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.image_generation(model=model, prompt=p, timeout=300)\nexcept BedrockError as e:\n    if e.status_code == 408:\n        resp = litellm.image_generation(model=model, prompt=p, timeout=600)  # one timed retry\n    else:\n        raise","preventionTips":["Always pass an explicit generous timeout for image generation (60-300s).","Treat 408 BedrockError as retryable with backoff.","Scale requested image count/resolution to your latency budget."],"tags":["bedrock","timeout","image-generation","httpx"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}