{"record":{"id":"4bee4a08f68c1eea","repo":"BerriAI/litellm","slug":"err-response-text-4bee4a","errorCode":null,"errorMessage":"{err.response.text}","messagePattern":"\\{err\\.response\\.text\\}","errorType":"http","errorClass":"BedrockError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_handler.py","lineNumber":231,"sourceCode":"                sync_stream=False,\n            )\n            completion_stream = decoder.aiter_bytes(response.aiter_bytes(chunk_size=stream_chunk_size))\n        else:\n            decoder = AWSEventStreamDecoder(model=model, json_mode=json_mode)\n            completion_stream = decoder.aiter_bytes(response.aiter_bytes(chunk_size=stream_chunk_size))\n\n        # LOGGING\n        logging_obj.post_call(\n            input=messages,\n            api_key=\"\",\n            original_response=\"first stream response received\",\n            additional_args={\"complete_input_dict\": data},\n        )\n\n        return completion_stream\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    except Exception as e:\n        raise BedrockError(status_code=500, message=str(e))\n\n\ndef make_sync_call(\n    client: HTTPHandler | None,\n    api_base: str,\n    headers: dict,\n    data: str,\n    signed_json_body: bytes | None,\n    model: str,\n    messages: list,\n    logging_obj: Logging,\n    fake_stream: bool = False,\n    json_mode: bool | None = False,\n    bedrock_invoke_provider: litellm.BEDROCK_INVOKE_PROVIDERS_LITERAL | None = None,","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/invoke_handler.py#L213-L249","documentation":"In the async streaming invoke path, raise_for_status() converts any 4xx/5xx into BedrockError with the upstream status code and response text. Because this fires before SSE parsing begins, it means the stream was never established — the failure happened at the HTTP layer.","triggerScenarios":"404 wrong model id on the invoke-model-with-response-stream endpoint; 403 missing bedrock:InvokeModelWithResponseStream permission; 429 throttled at connection time; 400 for streaming-unsupported configurations.","commonSituations":"IAM policies granting InvokeModel but not InvokeModelWithResponseStream (works non-streaming, fails streaming); typos in model ids; region mismatch between signing and endpoint.","solutions":["Inspect status_code; ensure IAM includes bedrock:InvokeModelWithResponseStream for streaming calls","Double-check the model id and the region in the endpoint URL","Use Router fallbacks or retries for throttling-induced 429s","If the model disallows streaming, fall back to a non-streaming call"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    stream = await litellm.acompletion(model=\"bedrock/...\", messages=msgs, stream=True)\nexcept BedrockError as e:\n    if e.status_code == 403:\n        raise PermissionError(\"Add bedrock:InvokeModelWithResponseStream to IAM for streaming\") from e\n    if e.status_code == 429:\n        await asyncio.sleep(2)\n        stream = await litellm.acompletion(model=\"bedrock/...\", messages=msgs, stream=True)\n    else:\n        raise","preventionTips":["Grant both InvokeModel and InvokeModelWithResponseStream in IAM","Test streaming permissions separately from non-streaming","Keep model id/region pairs in one validated config"],"tags":["bedrock","invoke","streaming","http-status","aws"],"backgroundTag":"http-error-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}