AI API Rate Limiting Guide 2026

Understand RPM, TPM, and RPD limits across all major AI providers. Build resilient systems that never hit a wall.

The Three Types of Rate Limits

Limit TypeStands ForWhat It Controls
RPMRequests Per MinuteHow many API calls you can make in 60 seconds
TPMTokens Per MinuteHow many tokens (input + output) you can process in 60 seconds
RPDRequests Per DayTotal API calls allowed in a 24-hour window
Key insight: You can hit TPM before RPM. A single request with 32K input tokens counts as one request but eats a huge portion of your TPM budget.

Rate Limits by Model (2026)

ModelRPMTPMNotes
GPT-4o5002,000,000Higher for enterprise tiers
DeepSeek V41,0005,000,000Very generous limits
Kimi K35002,000,000200K context may hit TPM faster
GLM-55002,000,000Consistent with OpenAI tier
Qwen-Plus5002,000,000Scales with commitment
Doubao Pro1,0004,000,000Higher for batch processing
Claude 3.54002,000,000Stricter RPM, generous TPM

* Limits vary by pricing tier and may change. Always check the provider's latest documentation.

Understanding HTTP 429 Errors

When you hit a rate limit, the API returns HTTP 429 with a Retry-After header telling you how many seconds to wait.

HTTP/1.1 429 Too Many Requests
Retry-After: 12
Content-Type: application/json

{
  "error": {
    "type": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Please retry after 12 seconds."
  }
}

Some providers also include headers showing your current usage:

x-ratelimit-limit-requests: 500
x-ratelimit-remaining-requests: 12
x-ratelimit-limit-tokens: 2000000
x-ratelimit-remaining-tokens: 450000

Exponential Backoff with Jitter

The industry-standard retry pattern. On 429, wait progressively longer between retries, plus random jitter to avoid thundering herd.

import random, time

def call_with_retry(func, max_retries=5):
    for attempt in range(max_retries):
        try:
            return func()
        except RateLimitError as e:
            if attempt == max_retries - 1:
                raise
            # Exponential backoff: 1s, 2s, 4s, 8s, 16s + random jitter
            delay = (2 ** attempt) + random.uniform(0, 1)
            time.sleep(delay)

Rate Limiting Best Practices

1. Monitor Your Headers

Always read the rate limit headers on every response. Track remaining quota and proactively slow down before hitting limits.

2. Use Token Buckets for Self-Throttling

Implement a client-side token bucket that mirrors the API's limits. This prevents 429s entirely by pacing requests before they leave your application.

3. Prioritize Requests

Not all requests are equal. Queue user-facing chat requests above background batch jobs. When approaching limits, defer non-critical work.

4. Batch When Possible

If you have 50 independent prompts, batching them into fewer requests with multiple messages saves RPM. But watch TPM — batched requests use more tokens per call.

5. Use Multiple Keys or a Gateway

For high-volume applications, distribute load across multiple API keys or use a gateway (like TokenEase) that automatically load-balances across provider endpoints.

6. Set Reasonable Timeouts

A hung request consumes your RPM slot. Set 30-60 second timeouts and retry with backoff rather than waiting indefinitely.

Rate Limits with TokenEase

TokenEase handles rate limiting automatically:

TokenEase routes your request to the fastest available endpoint. If DeepSeek is throttled, your call automatically goes to K3 or GLM-5 with zero code changes.

Never Worry About Rate Limits Again

TokenEase handles retries, load balancing, and fallback automatically. One API key. Unlimited scale.

Get Free API Key