{"record":{"id":"497b8111caeab1db","repo":"BerriAI/litellm","slug":"litellm-ratelimiterror-custom-llm-provider-excep","errorCode":null,"errorMessage":"litellm.RateLimitError: {custom_llm_provider}Exception - {error_str}","messagePattern":"litellm\\.RateLimitError: (.+?)Exception - (.+?)","errorType":"exception","errorClass":"RateLimitError","httpStatus":429,"severity":"warning","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":1168,"sourceCode":"            model=model,\n            llm_provider=custom_llm_provider,\n            litellm_debug_info=extra_information,\n            response=httpx.Response(\n                status_code=400,\n                request=httpx.Request(\n                    method=\"POST\",\n                    url=\" https://cloud.google.com/vertex-ai/\",\n                ),\n            ),\n        )\n    elif (\n        \"429 Quota exceeded\" in error_str\n        or \"Quota exceeded for\" in error_str\n        or \"Resource exhausted\" in error_str\n        or \"IndexError: list index out of range\" in error_str\n        or \"429 Unable to submit request because the service is temporarily out of capacity.\" in error_str\n    ):\n        raise RateLimitError(\n            message=f\"litellm.RateLimitError: {custom_llm_provider}Exception - {error_str}\",\n            model=model,\n            llm_provider=custom_llm_provider,\n            litellm_debug_info=extra_information,\n            response=httpx.Response(\n                status_code=429,\n                request=httpx.Request(\n                    method=\"POST\",\n                    url=\" https://cloud.google.com/vertex-ai/\",\n                ),\n            ),\n        )\n    elif (\n        isinstance(getattr(original_exception, \"status_code\", None), int)\n        and 500 <= original_exception.status_code < 600\n        and _get_body_error_code(error_str) == 429\n    ):\n        # upstream gateway wraps a 429 inside a 5xx envelope","sourceCodeStart":1150,"sourceCodeEnd":1186,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/litellm_core_utils/exception_mapping_utils.py#L1150-L1186","documentation":"The Vertex error string matched a quota condition — '429 Quota exceeded', 'Quota exceeded for', 'Resource exhausted', the 'temporarily out of capacity' 429 text, or (a litellm-specific quirk) 'IndexError: list index out of range' — and litellm maps it to RateLimitError with a synthetic 429 response. All of these mean back off: a project quota is exhausted or Vertex is temporarily out of capacity.","triggerScenarios":"Hitting per-minute RPM/TPM quotas for the model+region (e.g. gemini free-tier RPM limits); burst traffic on a project with low default quotas; regional capacity shortage for a newly released model returning the out-of-capacity 429 text.","commonSituations":"Fresh GCP projects with low default quotas; load or eval tests bursting requests; shared org quotas consumed by other teams; the IndexError string quirk making an unrelated client crash look like a quota error.","solutions":["Retry with exponential backoff honoring retry-after (litellm num_retries, or Router with cooldown_time)","Request a quota increase in the GCP console (IAM & Admin -> Quotas) for the specific model and region","Spread traffic across regions or projects to side-step a single quota","Cap client concurrency and batch requests to stay under RPM/TPM limits"],"exampleFix":"# before\nfor prompt in prompts:\n    litellm.completion(model='vertex_ai/gemini-1.5-flash', messages=[{'role': 'user', 'content': prompt}])\n# burst -> Quota exceeded\n\n# after\nfor prompt in prompts:\n    litellm.completion(\n        model='vertex_ai/gemini-1.5-flash',\n        messages=[{'role': 'user', 'content': prompt}],\n        num_retries=5,\n    )\n# plus: request RPM/TPM quota increase for the region","handlingStrategy":"retry","validationCode":"import time\n\nclass TokenBucket:\n    def __init__(self, rpm: int):\n        self.interval = 60.0 / rpm\n        self._last = 0.0\n    def acquire(self):\n        wait = self._last + self.interval - time.monotonic()\n        if wait > 0:\n            time.sleep(wait)\n        self._last = time.monotonic()\n\nbucket = TokenBucket(rpm=project_quota_rpm)  # acquired from GCP quota API\nbucket.acquire()  # before each vertex call","typeGuard":"import litellm\n\ndef is_vertex_quota_error(exc: BaseException) -> bool:\n    msg = str(exc)\n    return isinstance(exc, litellm.exceptions.RateLimitError) and any(\n        s in msg for s in ('Quota exceeded', 'Resource exhausted', 'out of capacity')\n    )","tryCatchPattern":"import litellm\nfrom litellm.exceptions import RateLimitError\n\ntry:\n    resp = litellm.completion(model='vertex_ai/gemini-1.5-flash', messages=messages)\nexcept RateLimitError:\n    # litellm honors Retry-After with num_retries; otherwise back off manually\n    time.sleep(30)\n    resp = litellm.completion(model='vertex_ai/gemini-1.5-flash', messages=messages, num_retries=5)","preventionTips":["Read project RPM/TPM quotas from the GCP quota API and client-side throttle to them","Use litellm.Router with cooldown_time so throttled deployments cool down automatically","Request quota increases before load tests and product launches, not after failures"],"tags":["vertex-ai","gcp","http-429","quota","rate-limit","retryable","litellm"],"backgroundTag":"quota-exceeded","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}