Start Building
Technical

LLM API 429 Errors: Retry Logic, Backoff & Fallback

Your LLM API returns 429. Do you sleep(1) and retry? Add jitter? Cascade to a backup provider? Here is exactly what production-grade rate limit handling looks like, and when it is simpler to eliminate the limit entirely.

Author photo
packet.ai Team
September 7, 2026

Handle LLM API 429 errors with exponential backoff starting at 500ms, doubling each attempt with +/-50% jitter, capped at 7 retries and 30 seconds, then cascade to a fallback provider. For solo developers and indie builders, the faster fix is removing the rate limit entirely: packet.ai's RTX Pro 6000 at $0.66/hr has no RPM ceiling and no TPM quota.

Key takeaways

  • LLM APIs enforce four independent rate limits simultaneously: RPM, TPM, RPD, and TPD. Hitting any one returns a 429, even if the other three have headroom.
  • Exponential backoff with jitter is the correct retry pattern. Without jitter, synchronized client retries generate a second wave of 429 errors larger than the first. This is the thundering herd problem.
  • Recommended schedule: 500ms, 1s, 2s, 4s, 8s with +/-50% random jitter. Max delay 30-60 seconds. Max attempts 5-7.
  • Retry-After headers exist but are not universally sent. Build your backoff logic to work without them.
  • Production systems need three layers: app-level backoff, provider-level fallback routing, and gateway-level request pooling.
  • For solo developers on Tier 1: packet.ai's RTX Pro 6000 at $0.66/hr removes RPM and TPM ceilings entirely, 68% below RunPod Secure Cloud's $2.09/hr for the same GPU.

Rate limiting is not an edge case. At any meaningful production scale, you hit it. OpenAI, Anthropic, Groq, Together AI. Every provider enforces per-minute and per-day limits on both request count and token volume. The first 429 usually comes as a surprise. The second one should not.

If you're on a Tier 1 API plan right now, this guide is for you. OpenAI Tier 1 caps GPT-4o at 500 RPM and 200,000 TPM. That sounds like headroom until you run a document pipeline or an agent making 15 calls per user action. packet.ai's Dynamic PODs give you a GPU with no RPM ceiling and no TPM quota. Just the tokens per second the hardware physically generates, at $0.66/hr for an RTX Pro 6000 (96 GB GDDR7 Blackwell), 68% below RunPod Secure Cloud's $2.09/hr for the same silicon.

This guide covers the mechanics of exponential backoff with jitter, what a production fallback chain looks like, circuit breakers, and how to read rate limit signals before the 429 hits. For understanding how inference speed affects your architecture decisions, see TTFT vs Tokens Per Second: Which LLM Performance Metric Matters for Your App. For a cost-first comparison of managed inference APIs, see Cheapest LLM API Providers in 2026.

How LLM API Rate Limits Actually Work

LLM rate limits are not a single counter. Most providers enforce four independent dimensions simultaneously, and your request fails the moment you exceed any one of them.

Limit typeWhat it measuresWhich workloads hit it first
RPMRequests per minute, regardless of token countAgentic workflows with many short calls
TPMTotal tokens (input + output) per minuteLong-context RAG pipelines and document processing
RPDTotal requests per 24-hour rolling windowHigh-frequency batch jobs running continuously
TPDTotal tokens per 24-hour rolling windowOvernight summarisation pipelines on large corpora

A single 40,000-token document prompt at Anthropic Tier 1 exhausts the entire per-minute input ceiling in one request, regardless of how many RPM remain. You can be well within your request count and still hit a 429 because one large request consumed the entire token window.

OpenAI's rate limit system operates on a token bucket model per API key. Tokens refill at a fixed rate per second. When the bucket empties, the API returns 429 until enough tokens accumulate. The provider does not always tell you how long to wait.

Most common mistake

Building retry logic that only watches RPM. TPM is the first limit hit on any workload processing documents longer than a few hundred words. Check your actual TPM consumption before assuming you understand your headroom.

Exponential Backoff with Jitter: The Correct Retry Pattern

Exponential backoff means waiting progressively longer between retry attempts. Each failure doubles the wait before the next attempt. Jitter adds a random offset to that wait. Both parts are required. Dropping either one makes 429 recovery slower in practice.

Without jitter, every client that hit the rate limit at the same moment waits the same duration before retrying. They all fire at once, generating a synchronized burst known as the thundering herd problem, which produces a second wave of 429s larger than the first. Naive retry loops create this reliably.

Retry attemptBase delayWith +/-50% jitterAction
1500ms250ms to 750msRetry
21s500ms to 1.5sRetry
32s1s to 3sRetry
44s2s to 6sRetry
58s4s to 12sRetry
616s8s to 24sRetry
730s cap15s to 45sReturn error to caller

The backoff formula: delay = min(base_delay x 2^(attempt-1) x jitter_factor, max_delay) where jitter_factor is a random float between 0.5 and 1.5. Cap maximum delay at 30-60 seconds regardless of attempt count. After 5-7 attempts, stop retrying and surface a clean error upstream.

A 429 from OpenAI sometimes includes a Retry-After header with the number of seconds to wait. When present, use it as the floor for your backoff delay. Do not go below it, but add jitter on top. Many providers do not send this header, so your logic must work without it.

Here is a minimal Python implementation you can drop into any project:

import time
import random

def call_with_backoff(fn, max_attempts=7, base_delay=0.5, max_delay=30):
    for attempt in range(1, max_attempts + 1):
        try:
            return fn()
        except RateLimitError as e:
            if attempt == max_attempts:
                raise
            retry_after = getattr(e, 'retry_after', None)
            base = max(retry_after or 0, base_delay * (2 ** (attempt - 1)))
            jitter = random.uniform(0.5, 1.5)
            delay = min(base * jitter, max_delay)
            time.sleep(delay)

Read headers on every response to throttle proactively before the 429 hits:

def check_headroom(response_headers):
    remaining = int(response_headers.get('x-ratelimit-remaining-tokens', 9999))
    limit = int(response_headers.get('x-ratelimit-limit-tokens', 9999))
    if limit > 0 and remaining / limit < 0.10:
        time.sleep(1)  # back off before the next call

packet.ai's RTX Pro 6000 at $0.66/hr delivers 96 GB GDDR7 Blackwell with no RPM ceiling and no TPM quota. Just the tokens per second the GPU physically generates. At 68% below RunPod Secure Cloud's $2.09/hr for the same silicon, it is the most cost-efficient single GPU for 30B-70B open-weight inference available to solo developers today.

Which HTTP Errors to Retry and Which to Fail Immediately

Not every error from an LLM API should trigger a retry. Retrying on the wrong status codes wastes time and can make things worse.

Retry these

  • 429: rate limit, transient
  • 500: internal server error, often transient
  • 502: bad gateway, usually transient
  • 503: service unavailable, transient
  • 504: gateway timeout, transient
  • Network timeouts and connection errors

Fail immediately on these

  • 400: bad request, payload is wrong
  • 401: authentication failed, fix the key
  • 403: forbidden, permission issue
  • 404: model or endpoint not found
  • Context window exceeded (413 or model-specific)
  • Content policy rejection

A 400 means your request is malformed. Retrying it returns the same 400 every time. A 429 means the infrastructure was temporarily overwhelmed. The exact same request will succeed once the rate window resets.

Provider Fallback Chains: Beyond Single-Provider Retry

Exponential backoff handles transient rate limits. When your RPM or TPM allocation is genuinely exhausted for the window, you need a different approach: routing to a different provider or model tier entirely.

A fallback chain is a prioritised list of inference targets. When the primary target returns a rate limit error that backoff cannot resolve within your latency budget, the router moves to the next target in the list.

1

Primary: your preferred provider at your preferred model tier

Best quality and cost for your workload. Attempt backoff here first before cascading.

2

Secondary: alternative provider with equivalent capability

Activated after 2-3 failed retries at the primary. OpenAI-compatible endpoints make this a config change, not a rewrite.

3

Tertiary: smaller, faster model on a different provider

Lower quality but always available. Good for classification or extraction tasks where output quality is less sensitive.

4

Graceful degradation: cached response, simplified output, or queue for later

Only when the task can tolerate latency or reduced fidelity. Never silently fail. Surface the degraded state to the user.

OpenAI-compatible APIs make provider fallback practical without rewrites. packet.ai's Token Factory is an OpenAI-compatible inference endpoint serving open-weight models, built to slot into the secondary or tertiary position of any fallback chain. For solo developers, it removes the per-provider rate limit ceiling at open-model cost. For a full comparison of how Token Factory stacks up against Groq and Together AI on price, see packet.ai Token Factory vs Groq vs Together AI: LLM API Pricing Compared. For a deeper look at what Token Factory is built for, see Who Is Token Factory For?

Circuit Breakers: Stopping the Retry Storm Before It Starts

A circuit breaker is a failure-rate monitor. When requests to a provider start failing above a set threshold, the circuit opens and routes all new requests around that provider without attempting a connection. After a cooldown period, a single test request determines whether to restore normal traffic.

Three states: Closed (normal, count failures), Open (provider bypassed, no retry attempts), Half-open (one test request after cooldown; close if it succeeds, reopen if it fails).

Circuit stateConditionWhat your application does
ClosedFailure rate within thresholdRoute normally. Count failures.
OpenFailure rate exceeded threshold (typically 50% in 60s)Skip provider entirely. Route to fallback. No retry attempts.
Half-openCooldown expired (30-120s)Allow one test request. Succeed: close. Fail: reopen.

The circuit breaker prevents your retry logic from spending its full budget on a provider whose daily token quota is exhausted and will not recover until midnight. Without it, your app fires thousands of retries against a wall. Add one when your workload can exhaust a provider's daily limit.

Read Rate Limit Headers Before the 429 Hits

LLM providers expose rate limit state through response headers on every successful request, not only on 429s. Reading these gives you a real-time view of remaining headroom so you can throttle proactively instead of reacting to errors.

HeaderWhat it tells youHow to use it
x-ratelimit-limit-requestsYour RPM ceiling for this API keyKnow your capacity
x-ratelimit-remaining-requestsRequests left in the current windowThrottle proactively when below 10%
x-ratelimit-remaining-tokensTokens left in the current minute windowThrottle or batch based on token budget
x-ratelimit-reset-requestsTimestamp when the request window resetsExact time to resume after full exhaustion
Retry-AfterSeconds to wait before retrying (on 429)Floor for backoff delay (not always sent)

When x-ratelimit-remaining-tokens drops below 10% of your limit, start spacing requests further apart before hitting zero. For batch workloads, stay below 70-80% of your TPM ceiling at all times. Proactive throttling prevents the 429 cycle entirely on predictable workloads.

Rate Limits by Provider: What Solo Developers Are Actually Working With

Rate limits vary by provider, model, and account tier. These figures reflect 2026 entry-level paid tiers. Verify against each provider's current documentation before finalising architecture decisions. These numbers change.

ProviderRPM (Tier 1)TPM (Tier 1)Which limit hits first
OpenAI (GPT-4o / GPT-4.1)500200,000RPM on agentic workloads
Anthropic (Claude Sonnet, verify at console)5050,000 input / 10,000 outputRPM is tight; ITPM on document workloads
Groq (free/dev tier)30 (free) / 1,000 (paid)12,000 (free) / 250,000 (paid)RPM on free tier; TPM on paid
DeepSeek60 (free tier)Varies by model, check docsRPM on free tier

Anthropic Tier 1 enforces four independent counters: RPM, input TPM, output TPM, and a daily dollar cap. Hit any one and you get a 429. This is why document pipelines on Anthropic hit limits faster than their RPM headroom suggests. Input tokens run out first.

OpenAI Tier 5 reaches 10,000 RPM for GPT-4o. Most solo developers and small teams never get there. Getting from Tier 1 to Tier 5 requires cumulative spend, not just time. A pipeline sending 50 requests per minute with 4,000 tokens each burns 200,000 TPM, right at the Tier 1 ceiling for GPT-4o.

The Solo Developer Fix: Self-Host and Remove Rate Limits for $0.66/hr

Every strategy above manages rate limits from a third-party provider. The most direct solution for a cost-sensitive solo developer: run your own inference stack and remove the per-minute limits from the architecture entirely.

On a dedicated GPU, the only constraint is hardware throughput. Tokens per second the GPU can generate. No RPM ceiling. No TPM quota. No daily request limit. packet.ai's RTX Pro 6000 at $0.66/hr on Dynamic PODs handles 30B-70B models in BF16 precision, 68% below RunPod Secure Cloud's $2.09/hr for the same GPU. For teams whose API bills are growing faster than their revenue, the break-even on switching to self-hosted inference is almost always below 50 million output tokens per month on models in the 30-70B range.

packet.ai's RTX Pro 6000 at $0.66/hr delivers 96 GB GDDR7 Blackwell performance on a Blackwell workstation GPU with 24,064 CUDA cores. It is the most cost-efficient single GPU for 30B-70B open-weight inference in 2026, at 68% below RunPod Secure Cloud's published rate for the same silicon.

The trade-off is operational: you manage the serving stack, handle model updates, and own the latency SLA. packet.ai's Dedicated PODs give single-tenant GPU access with a 99.99% SLA, removing the shared infrastructure variability that causes rate limiting on managed providers. For understanding the cost math in detail, see LLM Inference Cost in 2026: API Pricing and Cost per Million Tokens Compared.

ApproachRate limitsCost modelBest forpacket.ai price
Managed API (OpenAI, Anthropic)RPM + TPM + RPDPer token (frontier rates)Prototyping, low volume/
Managed inference API (Token Factory)Provider-levelPer token, open modelsFallback chain, no infraSee Token Factory
Self-hosted, Dynamic PODNone (hardware only)Per GPU-hour, no idle chargeDev, batch, bursty workloadsRTX Pro 6000 $0.66/hr
Self-hosted, Dedicated PODNone (hardware only)Per GPU-hour, 99.99% SLAProduction inferenceSee cluster options

Frequently Asked Questions About LLM API Rate Limits

RPM (requests per minute) counts API calls regardless of size. TPM (tokens per minute) counts combined input and output token volume. Both are enforced simultaneously. On real workloads with long prompts or documents, TPM is almost always the first limit hit. A single 40,000-token document exhausts the entire per-minute token budget in one request, even with hundreds of RPM remaining.
Without jitter, every client that hit the rate limit simultaneously waits the same duration before retrying. They all fire at once, generating a synchronized burst that produces a second wave of 429s larger than the first. Jitter of plus or minus 50% spreads retries across time, letting the rate window reset before clients try again.
5 to 7 attempts. Fewer than 5 gives up too early on transient limits that clear in seconds. More than 7 means your app blocks for over 60 seconds on a provider that may not recover within the rate window. After the final attempt, surface a clean error upstream. If you have a fallback provider, cascade to it after attempt 2 or 3 rather than exhausting the full retry budget on one target.
No. 400 and 401 are client errors. Your request is wrong, not the provider. Retrying returns the same error every time. Retry only on 429, 500, 502, 503, 504, and network-level errors. For 400, surface the error immediately for debugging. For 401, fail fast and alert on the credential problem.
A circuit breaker tracks failure rate to a provider. When failures exceed a threshold (typically 50% of requests in a 60-second window), it opens and routes all traffic around that provider without attempting connections. After a cooldown of 30-120 seconds, one test request determines whether to restore normal routing. Add one when your workload can exhaust a provider's daily token quota, because backoff logic will otherwise hammer a wall until midnight.
Read the x-ratelimit-remaining-requests and x-ratelimit-remaining-tokens headers on every successful response. When remaining tokens drop below 10% of your limit, start spacing requests further apart proactively. For batch workloads, stay below 70-80% of your TPM ceiling at all times. This prevents the 429 cycle entirely on predictable workloads.
Self-host an open-weight model on a rented GPU. packet.ai's RTX Pro 6000 at $0.66/hr on Dynamic gives you 96 GB GDDR7 Blackwell capacity with no RPM ceiling, no TPM quota, and no daily token limit. Just the tokens per second the GPU physically generates. At 68% below RunPod Secure Cloud's $2.09/hr for the same GPU, it is the most cost-efficient single card for 30B-70B model inference available today. Spin up in under 5 minutes, pay only for the hours you use.

On Tier 1 and hitting 429s?

packet.ai's RTX Pro 6000 at $0.66/hr removes rate limits entirely.

No RPM ceiling. No TPM quota. No 429. 68% below RunPod Secure Cloud for the same GPU. Spin up in under 5 minutes.

Last reviewed: September 7, 2026. GPU pricing verified from packet.ai/pricing. Rate limit figures from OpenAI and Anthropic documentation, September 2026. RunPod RTX Pro 6000 Secure Cloud rate confirmed at $2.09/hr (Community Cloud $1.69/hr). Provider rate limits change frequently. Verify against each provider's current documentation before finalising architecture decisions.

Waste less compute.

Same models. Same API. Fraction of the cost. Start free — no credit card required.

Start Building →

More from the blog