BerriAI/litellm · error · RateLimitError
{custom_llm_provider.capitalize()}Exception: Rate Limit Errr
Error message
{custom_llm_provider.capitalize()}Exception: Rate Limit Errror - {error_str} What it means
LiteLLM raises RateLimitError when the provider's error string contains the literal 'token_quota_reached', i.e. your account or key exhausted its token quota for the period. Note the message contains a typo ('Rate Limit Errror' with three r's), so string-matching on the message is unreliable — catch the exception type instead.
Source
Thrown at litellm/litellm_core_utils/exception_mapping_utils.py:733
error_str += "XXXXXXX" + '"'
raise AuthenticationError(
message=f"{custom_llm_provider.capitalize()}Exception: Authentication Error - {error_str}",
llm_provider=custom_llm_provider,
model=model,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif ExceptionCheckers.is_error_str_context_window_exceeded(error_str):
raise ContextWindowExceededError(
message=f"{custom_llm_provider.capitalize()}Exception: Context Window Error - {error_str}",
model=model,
llm_provider=custom_llm_provider,
response=getattr(original_exception, "response", None),
litellm_debug_info=extra_information,
)
elif "token_quota_reached" in error_str:
raise RateLimitError(
message=f"{custom_llm_provider.capitalize()}Exception: Rate Limit Errror - {error_str}",
llm_provider=custom_llm_provider,
model=model,
response=getattr(original_exception, "response", None),
)
elif "The server received an invalid response from an upstream server." in error_str:
raise litellm.InternalServerError(
message=f"{custom_llm_provider.capitalize()}Exception - {original_exception.message}",
llm_provider=custom_llm_provider,
model=model,
)
elif "model_no_support_for_function" in error_str:
raise BadRequestError(
message=f"{custom_llm_provider.capitalize()}Exception - Use 'watsonx_text' route instead. IBM WatsonX does not support `/text/chat` endpoint. - {error_str}",
llm_provider=custom_llm_provider,
model=model,
)
elif hasattr(original_exception, "status_code"):View on GitHub (pinned to 6c2dcb801b)
Solutions
- Wait for the quota window to reset, or request a quota increase / top up the key.
- Switch to a different API key or provider via litellm.Router fallbacks.
- Track token usage (litellm's success callbacks) and alert before hitting the cap.
- If you control the gateway, raise the token quota for that key.
Example fix
# before
try:
resp = litellm.completion(model=..., messages=msgs)
except litellm.RateLimitError as e:
if "Errror" in str(e): # fragile string matching
...
# after
try:
resp = litellm.completion(model=..., messages=msgs)
except litellm.RateLimitError:
# handle by type; message text ('Rate Limit Errror') may change between versions
time.sleep(60)
resp = litellm.completion(model=..., messages=msgs) Defensive patterns
Strategy: retry
Type guard
import litellm
def is_token_quota_error(e: BaseException) -> bool:
return isinstance(e, litellm.RateLimitError) and "token_quota_reached" in str(e) Try / catch
try:
resp = litellm.completion(model=m, messages=msgs)
except litellm.RateLimitError as e:
if "token_quota_reached" in str(e):
wait_until_quota_reset() # or rotate to another key/model
else:
raise Prevention
- Monitor cumulative token usage with litellm success callbacks and alert near the quota.
- Do not match on the message text (it contains a typo and may change); match the exception type plus the provider token.
- Keep a secondary API key/model configured for quota exhaustion.
When it happens
Trigger: A completion() call against a provider/gateway (e.g. Cloudflare AI Gateway or an internal gateway) that returns 'token_quota_reached' in its error body once the configured token budget is spent.
Common situations: Teams with per-key token budgets on a gateway, free-tier keys with daily caps, CI loops burning through quota, or shared proxy keys where one workload exhausts the pool.
Related errors
- litellm.RateLimitError: {custom_llm_provider.capitalize()}Ex
- Project tpm_limit ({data.tpm_limit}) exceeds team's tpm_limi
- Project rpm_limit ({data.rpm_limit}) exceeds team's rpm_limi
- Missing keys={missing_keys} in environment.
- External Customer ID is not set. Charge_by={charge_by}. User
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/55e431f48d47a6e5.
Report an issue: GitHub.