BerriAI/litellm · error · BedrockError
err.response.text
Error message
err.response.text
What it means
In the synchronous image_edit path, the httpx response passes through raise_for_status(); a 4xx/5xx becomes httpx.HTTPStatusError which LiteLLM converts to BedrockError carrying the AWS status code and the raw response body as message. The text usually contains Bedrock's modeled error (e.g. ValidationException, AccessDeniedException, ThrottlingException XML/JSON).
Source
Thrown at litellm/llms/bedrock/image_edit/handler.py:117
model=model,
logging_obj=logging_obj,
prompt=prompt,
model_response=model_response,
client=(client if client is not None and isinstance(client, AsyncHTTPHandler) else None),
)
if client is None or not isinstance(client, HTTPHandler):
client = _get_httpx_client()
try:
response: Final = client.post(
url=prepared_request.endpoint_url,
headers=prepared_request.prepped.headers,
data=prepared_request.body,
)
response.raise_for_status()
except httpx.HTTPStatusError as err:
error_code: Final = err.response.status_code
raise BedrockError(status_code=error_code, message=err.response.text)
except httpx.TimeoutException:
raise BedrockError(status_code=408, message="Timeout error occurred.")
### FORMAT RESPONSE TO OPENAI FORMAT ###
model_response = self._transform_response_dict_to_openai_response(
model_response=model_response,
model=model,
logging_obj=logging_obj,
prompt=prompt,
response=response,
data=prepared_request.data,
)
return model_response
async def async_image_edit(
self,
prepared_request: BedrockImageEditPreparedRequest,
timeout: float | httpx.Timeout | None,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Inspect BedrockError.message — it embeds the AWS error type and detail; act on that (enable model access, fix params, add IAM policy).
- For 403: grant bedrock:InvokeModel (and foundation-model ARN access) to the signing credentials.
- For 404/validation: confirm the model id is enabled in the region and the body params match Nova/Stability schemas.
- For 429: retry with backoff or raise your Bedrock quota/TPS limits.
Defensive patterns
Strategy: try-catch
Try / catch
from litellm.exceptions import BedrockError
try:
resp = litellm.image_edit(model=model, image=img, prompt=prompt)
except BedrockError as e:
if e.status_code == 429:
backoff_and_retry() # throttling
elif e.status_code == 403:
alert_iam() # bedrock:InvokeModel missing
elif e.status_code == 404:
enable_model_in_region() # model access
else:
log_and_surface(e.message) # body contains AWS error detail Prevention
- Enable model access in every target region before deploying.
- Grant least-privilege IAM including bedrock:InvokeModel on the model ARNs you call.
- Route 429s into an exponential-backoff retry policy.
When it happens
Trigger: Bedrock InvokeModel for image edits returning 400 (malformed body/params), 403 (IAM missing bedrock:InvokeModel), 404 (model not enabled in region), 429 (throttling), or 5xx; triggered on the sync handler after request signing succeeds.
Common situations: Model not enabled in the target region's model access settings; missing IAM InvokeModel permission; payload validation failures from bad task params (e.g. bad base64 image); TPS limit exceeded on stability/nova endpoints.
Related errors
- BedrockException PermissionDeniedError - {error_str}
- BedrockException: Rate Limit Error - {error_str}
- raw_response.text
- OUTPAINTING requires either a mask image or a mask prompt. P
- Unsupported Amazon Nova Canvas taskType: {task_type!r}. Use
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/237e40c44efe235e.
Report an issue: GitHub.