{"record":{"id":"d9bb083a662d9691","repo":"BerriAI/litellm","slug":"bedrockexception-rate-limit-error-error-str","errorCode":null,"errorMessage":"BedrockException: Rate Limit Error - {error_str}","messagePattern":"BedrockException: Rate Limit Error - (.+?)","errorType":"exception","errorClass":"RateLimitError","httpStatus":429,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":876,"sourceCode":"    elif (\n        \"Unable to locate credentials\" in error_str\n        or \"The security token included in the request is invalid\" in error_str\n    ):\n        raise AuthenticationError(\n            message=f\"BedrockException Invalid Authentication - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"AccessDeniedException\" in error_str:\n        raise PermissionDeniedError(\n            message=f\"BedrockException PermissionDeniedError - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"throttlingException\" in error_str or \"ThrottlingException\" in error_str:\n        raise RateLimitError(\n            message=f\"BedrockException: Rate Limit Error - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"Connect timeout on endpoint URL\" in error_str or \"timed out\" in error_str:\n        raise Timeout(\n            message=f\"BedrockException: Timeout Error - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n        )\n    elif \"Could not process image\" in error_str:\n        raise litellm.InternalServerError(\n            message=f\"BedrockException - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n        )\n    elif hasattr(original_exception, \"status_code\"):","sourceCodeStart":858,"sourceCodeEnd":894,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/exception_mapping_utils.py#L858-L894","documentation":"Bedrock-specific: RateLimitError raised when the AWS error text contains 'throttlingException' or 'ThrottlingException'. AWS is throttling the request because you exceeded your account's limits for the model — on-demand TPM/RPM quotas or provisioned throughput capacity.","triggerScenarios":"Bursts or sustained load beyond the model's on-demand quota (per-model TPM/RPM), too many concurrent streams, or provisioned-throughput endpoints saturated. Bedrock returns ThrottlingException with HTTP 400, so generic status mapping would miss it — hence this keyword rule.","commonSituations":"Batch/eval jobs fanning out across many workers, agent loops with tight iteration, default low quotas for newly enabled models, or multiple teams sharing one AWS account's quota.","solutions":["Retry with exponential backoff and jitter — ThrottlingException is standard retryable (num_retries + retry_after).","Throttle clients: litellm.Router with rpm/tpm settings per bedrock deployment; honor model-level quotas.","Request a quota increase (Service Quotas console) or buy provisioned throughput for steady load.","Cache identical responses to reduce call volume."],"exampleFix":"# before\nfor m in batch:\n    out.append(litellm.completion(model=\"bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0\", messages=[m]))\n\n# after\nfrom litellm import Router\nrouter = Router(\n    model_list=[{\"model_name\": \"b\", \"litellm_params\": {\"model\": \"bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0\", \"rpm\": 50, \"tpm\": 50000}}],\n    num_retries=5, retry_after=20,\n)\nfor m in batch:\n    out.append(router.completion(model=\"b\", messages=[m]))","handlingStrategy":"retry","validationCode":null,"typeGuard":"import litellm\n\ndef is_bedrock_throttle(e: BaseException) -> bool:\n    return isinstance(e, litellm.RateLimitError) and getattr(e, \"llm_provider\", \"\") == \"bedrock\"","tryCatchPattern":"try:\n    resp = litellm.completion(model=\"bedrock/...\", messages=msgs, num_retries=5, retry_after=20)\nexcept litellm.RateLimitError:\n    router.completion(model=\"bedrock-fallback\", messages=msgs)","preventionTips":["Set Router rpm/tpm matching your account's per-model Bedrock quotas.","Use exponential backoff with jitter — Bedrock throttles hard on bursts.","Raise on-demand quotas via Service Quotas or use provisioned throughput for steady load."],"tags":["bedrock","throttling","rate-limit","aws","retry","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}