BerriAI/litellm · error · BedrockError
{err.response.text}
Error message
{err.response.text} What it means
Synchronous Bedrock rerank POST returned non-2xx; the httpx.HTTPStatusError is re-raised as BedrockError with the upstream status code and raw response body ({err.response.text}). This is the sync twin of the async guard and surfaces the bedrock-agent-runtime error JSON verbatim.
Source
Thrown at litellm/llms/bedrock/rerank/handler.py:117
return self.arerank(
prepared_request,
timeout=timeout,
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=dict(prepared_request["prepped"].headers),
data=prepared_request["body"],
timeout=timeout,
)
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.")
logging_obj.post_call(
original_response=response.text,
api_key="",
)
response_json: Final = response.json()
return BedrockRerankConfig()._transform_response(response_json)
def _prepare_request(
self,
model: str,
api_base: str | None,
extra_headers: dict | None,
data: dict,View on GitHub (pinned to 6c2dcb801b)
Solutions
- Parse the message body for the AWS error code and fix the named field/permission.
- Confirm the rerank model ID and region; enable model access in the Bedrock console.
- For 429, back off and retry; reduce requests per second.
- Validate documents (non-empty strings/dicts) before the call.
Defensive patterns
Strategy: try-catch
Try / catch
try:
result = litellm.rerank(model=model, query=q, documents=docs)
except BedrockError as e:
if e.status_code == 400:
raise InvalidRerankRequest(e.message) from e # body has AWS ValidationException detail
if e.status_code == 429:
backoff_and_retry()
raise Prevention
- Sanitize query/documents before calling rerank.
- Keep the AWS error body in logs — it pinpoints the offending field.
- Only retry 429/5xx statuses.
When it happens
Trigger: litellm.rerank(model='bedrock/<rerank-model>', ...) hitting ValidationException (bad params), ThrottlingException (429), AccessDeniedException (403), or ResourceNotFoundException (unknown model).
Common situations: Model access not enabled for the rerank model in the chosen region, oversized document lists, wrong model ID format, missing IAM permission on bedrock-agent-runtime.
Related errors
- err.response.text
- err.response.text
- APIError: {exception_provider} - {error_str}
- Timeout error occurred.
- Missing boto3 to call bedrock. Run 'pip install boto3'.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/a67df0aafb57c05f.
Report an issue: GitHub.