HTTP 429 Too Many Requests: Safe Retry-After Parsing and Exponential Backoff
A practical developer guide to resolving HTTP 429 errors in LLM APIs: parsing rate limit headers, preventing retry storms, and implementing exponential backoff.
An HTTP 429 Too Many Requests error indicates that an application has exceeded the API provider's rate limits or token quotas. Uncontrolled, immediate retries only make matters worse by triggering cascading retry storms and prolonged account lockouts.
To build resilient production pipelines, developers must accurately distinguish between request-rate (RPM) limits, token-throughput (TPM) limits, and billing boundaries, parse the Retry-After header correctly, and implement an exponential backoff strategy with randomized jitter.
Understanding HTTP 429 in LLM APIs
When integrating large language model APIs (such as OpenAI, Anthropic, or compatible multi-model gateways), 429 status codes typically stem from three distinct mechanisms:
- RPM (Requests Per Minute): Triggered when concurrent workers fire too many parallel requests without queue orchestration.
- TPM (Tokens Per Minute): Triggered when combined prompt context and generation tokens exceed rolling minute-by-minute token budgets.
- Quota or Balance Exhaustion: Hard limits resulting from exhausted prepaid credits, zero balance, or strict monthly spend caps.
When an error is caused by credit exhaustion or rigid 5-hour subscription locks, automated retries waste network bandwidth and worker threads. To immediately isolate the root cause instead of parsing cryptic error payloads, BetterToken provides an observability Dashboard: it displays real-time HTTP status codes, granular breakdown of input, output, and cache tokens per request, and transparent pay-as-you-go balances without disruptive 5-hour rolling lockout windows.
HTTP 429 Diagnostic Matrix
Correctly Parsing the Retry-After Header
According to RFC 6585, the Retry-After response header communicates the required wait interval in two standard formats:
- Relative seconds (integer or decimal, e.g.,
Retry-After: 12); - HTTP-date timestamp (e.g.,
Retry-After: Sun, 23 Aug 2026 03:05:00 GMT).
Implementing Full Jitter Exponential Backoff
When the Retry-After header is absent, use exponential backoff enhanced with Full Jitter. The wait duration for attempt is calculated as:
Randomizing delay spreads out retries across workers, breaking concurrent lockstep and preventing server overload.
Idempotency and Side-Effect Safety
Retrying read-only operations (GET) is inherently idempotent. However, when invoking LLM inference or agent tasks via POST:
- Prevent Duplicate Agent Execution: If a network timeout occurs mid-generation, inspect whether tokens were consumed or output persisted before blindly re-dispatching.
- Assign Client Request IDs: Include unique
X-Request-IDheaders to trace retried calls in upstream logs. - Never Treat 401/403 as 429: Authentication errors cannot be resolved by backoff loops; they require credential renewal.
Verifying Recovery
Before resuming high-throughput workloads:
- Dispatch a minimal health-check probe (
max_tokens: 5). - Verify HTTP 200 and inspect
x-ratelimit-remaining-requests. - Gradually ramp up concurrency while tracking 429 error ratios in monitoring dashboards.
To eliminate sudden 429 bottlenecks caused by rigid minute limits and maintain complete visibility into request status, switch to BetterToken API, generate dedicated API keys, and monitor real-time token telemetry in the Dashboard.