BerriAI/litellm · error · BedrockError
{response.text}
Error message
{response.text} What it means
First gate in the shared async invoke handler: any non-200 status on the POST raises BedrockError carrying that status and the raw body text. It covers the fake-stream and non-streaming paths before any parsing is attempted, so the message is AWS's own error document.
Solutions
- Read e.status_code and the message in e.message for the AWS-stated reason
- Validate optional_params against the specific model's supported inference configuration
- Verify model id, region, and account model access; check IAM permissions
- Retry on 429/5xx via num_retries or Router fallback deployments
Defensive patterns
Strategy: try-catch
Try / catch
try:
resp = await litellm.acompletion(model="bedrock/...", messages=msgs)
except BedrockError as e:
if e.status_code == 400:
raise ValueError(f"Model rejected inference params: {e.message}") from e
if e.status_code in (429, 500, 503):
await asyncio.sleep(2)
resp = await litellm.acompletion(model="bedrock/...", messages=msgs)
else:
raise Prevention
- Validate per-model supported params (some Bedrock models reject topK/topP combos)
- Verify model ids include version suffixes
- Set num_retries for throttling resilience
When it happens
Trigger: 403 access denied (credentials lack bedrock:InvokeModel), 404 unknown model id, 400 for parameters the model rejects (e.g. topK/topP combinations), 429 throttling, and 5xx service errors on the invoke-model endpoint.
Common situations: Model ids missing the version suffix (:0); inference params not supported by a specific Bedrock model; models not available in the configured region; throttling during traffic spikes.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/cd35775996537c2b.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/bedrock/chat/invoke_handler.py:187
client = get_async_httpx_client(
llm_provider=litellm.LlmProviders.BEDROCK,
params=(
{"ssl_verify": logging_obj.litellm_params.get("ssl_verify")}
if logging_obj and logging_obj.litellm_params and logging_obj.litellm_params.get("ssl_verify")
else None
),
) # Create a new client if none provided
response: Final = await client.post(
api_base,
headers=headers,
data=data,
stream=not fake_stream,
logging_obj=logging_obj,
)
if response.status_code != 200:
raise BedrockError(status_code=response.status_code, message=response.text)
if fake_stream:
model_response: Final[ModelResponse] = litellm.AmazonConverseConfig()._transform_response(
model=model,
response=response,
model_response=litellm.ModelResponse(),
stream=True,
logging_obj=logging_obj,
optional_params={},
api_key="",
data=data,
messages=messages,
encoding=litellm.encoding,
)
completion_stream: Any = MockResponseIterator(model_response=model_response, json_mode=json_mode)
elif bedrock_invoke_provider == "anthropic":
decoder: AWSEventStreamDecoder = AmazonAnthropicClaudeStreamDecoder(
model=model,View on GitHub (pinned to 77b7c6c40c)