Skip to content

Rate Limiting

Rate limiting is enforced by your AI provider (OpenAI, Anthropic, Google, and so on), not by Amplify itself. Amplify does not impose its own request or token caps on you. What Amplify does do is adapt to the limits your provider already enforces, so you hit fewer 429 Too Many Requests errors and waste fewer tokens on rejected requests.

This page explains the three kinds of provider limits, why the tokens-per-minute (TPM) limit exists and why it matters even when your context window is huge, and the three mechanisms Amplify uses to stay under your provider's ceilings.

The three provider limits

Most providers enforce rate limits along three independent axes. Hitting any of them returns HTTP 429 and (on some providers) a temporary account-level cooldown.

LimitUnitWhat it countsExample
TPM — Tokens Per Minutetokens / 60sTotal tokens (input + output combined) sent to your account in the rolling 60-second window250,000 TPM
RPM — Requests Per Minuterequests / 60sNumber of separate API calls made in 60 seconds60 RPM
RPD — Requests Per Dayrequests / 24hNumber of separate API calls made in 24 hours1,000 RPD

A value of 0 means unlimited for that axis on that provider/tier.

They are independent

You can be under TPM but over RPM (many tiny requests), or under RPM but over TPM (one giant request). Both return 429. This is why Amplify tracks all three, not just TPM.

Why TPM is necessary (and why it bites before the context window does)

The most counter-intuitive limit is TPM. People often ask: "Gemini has a 1-million-token context window, so why did my 300K-token request get rate-limited?"

The answer is that the context window and the TPM cap measure different things:

  • Context window = how many tokens fit in a single request (the model's working memory for one call).
  • TPM = how many tokens your account may consume in total across all requests in a 60-second window.

These exist for an infrastructural reason: providers run shared GPU inference clusters. A single forward pass over a 300K-token prompt occupies VRAM and compute on GPUs that dozens of other tenants are sharing. The provider cannot let one account monopolise the cluster, so they cap the total tokens-per-minute per account tier. TPM is the fairest way to allocate shared compute: whoever you are, you get N tokens of GPU time per minute, no more.

The practical consequence:

ModelAdvertised contextTypical TPM (mid tier)What happens
Gemini 1.5 Pro1,000,000 tokens~250,000 TPMA single 300K request fits the context window but exceeds TPM429
GPT-4o128,000 tokens~150,000 TPMTwo back-to-back 100K requests exceed TPM even though each fits the context
Claude 3.5 Sonnet200,000 tokens~120,000 TPMOne maxed-out request + any second request blows past TPM

So TPM is necessary because the context window is a per-request ceiling; TPM is a per-account-per-minute ceiling on shared hardware. The context window being large does not mean your minute-level token budget is large. When the two disagree, TPM wins and you get 429.

This is also why Amplify's rate-limit handling focuses so heavily on TPM rather than just RPM: the most common real-world 429 for someone using a long-context model is a TPM violation, not an RPM violation.

How Amplify adapts (it does not impose limits)

To be explicit: Amplify does not rate-limit you. It does not throttle your requests for its own sake, and it does not set ceilings lower than what your provider allows. What it does is read the limits you've configured for each provider (in Settings) and steer requests so they're more likely to succeed against your provider's limits.

There are three adaptation mechanisms, all of which react to provider limits rather than impose new ones:

  • 1. Pre-Flight Check

    Before sending a request, Amplify estimates its token cost (prompt tokens + expected completion budget) and compares it against your remaining TPM for the current 60-second window.

    • If the request would fit under remaining TPM → send immediately.
    • If it would exceed remaining TPM → Amplify waits until enough TPM has replenished (the rolling window slides forward), then sends.

    This turns a hard 429 rejection into a short, predictable wait. The provider still enforces the limit; Amplify just avoids triggering it.

  • 2. RPM Throttling

    For providers with a tight RPM cap, Amplify spaces out consecutive requests so you don't fire 60 calls in the first second of a minute and then sit idle for 59. This is a client-side pacing layer — it never sends more requests than your RPM allows, but it also doesn't artificially cap you below your plan.

  • 3. Auto-Shrink to TPM

    When a request's estimated token cost would exceed remaining TPM and the window won't replenish in time, Amplify can auto-shrink the request: it trims non-essential context (older memory entries, lower-priority skill descriptions) to bring the request under the TPM ceiling. This is a last resort before waiting — it lets the conversation continue with slightly less context rather than blocking entirely.

All three adapt; none impose

Every mechanism above uses your configured provider limits as the ceiling. If you set TPM to 0 (unlimited), the pre-flight check passes instantly, there's nothing to throttle, and nothing to shrink. Amplify only ever constrains you to match the limits you told it about — it never adds limits of its own.

Configuring limits per provider

You set TPM / RPM / RPD per provider in the Settings → Providers panel. Each provider entry has three numeric fields; leave a field at 0 for "unlimited".

yaml
# amplify.config.yaml — provider rate-limit configuration
providers:
  openai:
    apiKey: ${OPENAI_API_KEY}
    rateLimits:
      tpm: 150000      # tokens per minute (0 = unlimited)
      rpm: 60           # requests per minute (0 = unlimited)
      rpd: 0            # requests per day (0 = unlimited)
  anthropic:
    apiKey: ${ANTHROPIC_API_KEY}
    rateLimits:
      tpm: 120000
      rpm: 50
      rpd: 0
  google:
    apiKey: ${GOOGLE_API_KEY}
    rateLimits:
      tpm: 250000
      rpm: 100
      rpd: 0

Limits are persisted per provider in localStorage under the amplify:rate-limits key, and the wire format serialised for the server is produced by getRateLimitWire(). The Settings panel reads/writes the same store, so changes take effect on the next request without a restart.

  • Suggested defaults by provider

    These are conservative mid-tier defaults — adjust to match your actual plan. 0 = unlimited.

    ProviderTPMRPMRPD
    OpenAI (GPT-4o tier)150,000600
    Anthropic (Claude 3.5)120,000500
    Google (Gemini 1.5 Pro)250,0001000
    Groq30,0003014400
    DeepSeek60,000600
    OpenRouter200,0002000
    Mistral150,000500
    Cohere100,0001000
    Together AI80,000600
    Fireworks AI80,000600
    Perplexity50,000500
    AI2160,000500
    Ollama (local)000
    LM Studio (local)000
Local providers (Ollama, LM Studio)

Local providers run on your own hardware, so there's no shared-cluster reason to cap TPM. Leave all three limits at 0 (unlimited) — the only real ceiling is your GPU/CPU throughput, which the provider itself surfaces as latency rather than 429s.

Common issues

SymptomCauseFix
429 Too Many Requests immediately on first requestTPM/RPM set below the request's actual sizeRaise TPM in Settings, or set 0 if your plan is unlimited
Requests work for a while, then start failing in burstsYou're hitting TPM mid-window; the rolling 60s hasn't replenishedEnable Auto-Shrink, or lower the per-request context budget
Long-context model (Gemini 1M) rejects large prompts that "should fit"Context window ≠ TPM — the request fits context but exceeds per-minute tokensRaise TPM to match your tier, or send smaller prompts more frequently
Groq returns 429 with a long retry-afterGroq enforces strict daily (RPD) limits on free tierSwitch provider or upgrade Groq tier; lower RPM
Everything was fine, then suddenly all 429 after a config changeSettings panel wrote a very low RPM/TPMRe-check Settings → Providers values
Local Ollama still gets "rate limited"A non-zero limit was set by mistakeSet all three limits to 0 for local providers

Back to LLM Providers