{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L858-L894","documentation":"LiteLLM throws RateLimitError when Bedrock returns throttlingException (either capitalization matched at litellm/litellm_core_utils/exception_mapping_utils.py:876): account-level requests/tokens-per-minute quotas for the model, or OnDemand capacity limits, were exceeded. It is the one Bedrock client error that is expected and retriable - backoff and quota management are the intended responses.","triggerScenarios":"Bursty or sustained litellm.completion(model='bedrock/...') traffic exceeding the model's TPM/RPM quota; high-concurrency proxy load funneled to a single model id; parallel test suites hammering one endpoint.","commonSituations":"Load tests against a single model; production traffic spikes; low default quotas on newly enabled models; naive retry loops without jitter that amplify throttling.","solutions":["Enable managed retries with backoff: litellm.completion(..., num_retries=3) (proxy: litellm_settings num_retries plus cooldown_time)","Reduce concurrency or spread load across model ids / inference profiles, each with its own quota","Request a TPM/RPM quota increase in AWS Service Quotas for the model","Configure litellm.Router with fallback deployments so throttled calls overflow to another model/provider"],"exampleFix":"# before\nresp = litellm.completion(model=\"bedrock/anthropic.claude-3-sonnet-...\", messages=msgs)  # throttlingException\n\n# after\nresp = litellm.completion(model=\"bedrock/anthropic.claude-3-sonnet-...\", messages=msgs, num_retries=4)","handlingStrategy":"retry","validationCode":null,"typeGuard":"import litellm\n\ndef is_rate_limit(e: BaseException) -> bool:\n    return isinstance(e, litellm.RateLimitError)","tryCatchPattern":"import random, time\nimport litellm\n\nfor attempt in range(5):\n    try:\n        return litellm.completion(model='bedrock/...', messages=msgs)\n    except litellm.RateLimitError:\n        time.sleep((2 ** attempt) + random.random())\n# or simply: litellm.completion(..., num_retries=4) — litellm backs off automatically","preventionTips":["Set num_retries and Router cooldown_time on proxy deployments","Size client concurrency to the model's documented TPM/RPM quota","Request quota increases before launch, not after throttling starts","Spread load across model ids / inference profiles with separate quotas"],"tags":["bedrock","rate-limit","throttling","quotas"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}