API Rate Limiting for LLM Apps: Quotas, Backoff and Cost Control
API rate limiting for LLM apps explained: RPM and TPM quotas, reading a 429, exponential backoff with jitter, and cost controls that keep your app running.
By Galactic News Editorial · Published 2026-11-23T14:02:50+00:00 · Updated 2026-11-23T14:02:50+00:00
API Rate Limiting for LLM Apps: Quotas, Backoff and Cost Control
Every language model API limits how fast you can call it. Hit the limit and the API answers with a 429 error. Your app stalls, your users wait, and your bill can still climb. This guide explains how API rate limiting for LLM apps works, how quotas differ between providers, and how backoff and cost control keep your app running.
The core idea is simple. Providers limit requests per minute, tokens per minute, and often requests per day. Your job is to stay under those ceilings and to fail gracefully when you cross one.
How LLM API quotas work
Language model APIs limit traffic in two ways at once: how many requests you send per minute (RPM) and how many tokens you use per minute (TPM). You can stay well under your request limit and still get throttled because a few long prompts used up your token budget.
OpenAI measures RPM, requests per day, TPM and tokens per day, per organisation and project, per model. Whichever limit runs out first triggers the error. A request counts as the higher of max_tokens and an estimate based on its characters. Failed requests count too.
Azure OpenAI works differently. You assign TPM to each deployment, and the RPM limit is set in proportion to it. RPM is checked over windows of one or ten seconds, so a burst can get a 429 even when the per-minute total looks fine.
Anthropic limits RPM, input tokens per minute and output tokens per minute, per model. Capacity refills continuously. A 60 RPM limit may be enforced as one request per second. Cached input tokens do not count toward the input limit on most models, and max_tokens does not count toward the output limit.
Rate limits apply at the organisation and project level. They are not assigned to individual API keys. Minting extra keys does not mint extra quota. OpenAI also lets organisations split quotas across projects, so an experimental script cannot eat the production quota.
Reading a 429: not every error means wait
A 429 is not always a retry signal. The first job is to work out which limit fired, because the fixes point in opposite directions.
Some 429s mean wait and retry. A plain rate limit, a slow_down error when traffic grew too fast, and a 503 server overload all clear with time. Others mean stop and tell someone. OpenAI returns error codes such as credit_balance_exhausted, organisation_spend_limit_exceeded and project_spend_limit_exceeded. Retrying will not restore access for those.
Anthropic returns a 429 rate_limit_error with a retry-after header, and a 529 overloaded_error when the service is busy. A 429 for the monthly spend cap has no retry-after header and keeps failing until access resumes.
The response itself tells you what happened. OpenAI sends a retry-after header with the minimum seconds to wait, plus x-ratelimit headers showing the ceiling, what is left, and when each counter resets. Read the headers. They are the fastest diagnosis you have.
Backoff: the retry pattern that works
When a retry is the right move, the pattern is exponential backoff with jitter. Wait a short time, retry, and double the wait after each failure. Add random jitter so many clients do not retry at the same instant.
Always honour the Retry-After header when the API sends one. OpenAI and Anthropic send it in seconds. Azure OpenAI sends retry-after-ms in milliseconds. Without a hint, back off exponentially and cap both the number of attempts and the total time.
Know what your SDK already does. The OpenAI and Anthropic Python SDKs retry connection errors and 408, 409, 429 and 5xx responses two times by default. If you add your own retry loop, turn off the SDK's retries, for example with max_retries=0 in Python. Otherwise the attempts multiply and you burn quota on retries of retries.
Two more rules from the provider docs. Ramp up gradually, because a sharp jump in traffic triggers slow_down and acceleration limits even inside your quota. OpenAI suggests growing by no more than 50 percent every 15 minutes once you reach one million input tokens per minute. And do not replay a stream you already consumed, because an error after a stream starts can arrive as a stream event.
API rate limiting LLM apps quotas backoff and cost control
Your ceilings depend on your usage tier. OpenAI promotes tiers automatically as cumulative spend grows. Higher tiers raise the monthly usage limit. Check your own limits page in the provider dashboard rather than trusting a third-party table, because per-model numbers change as models ship.
Cost control starts before the call. Set max_tokens close to the response size you expect. On OpenAI and Azure OpenAI, the full max_tokens value counts against your TPM limit even if the model returns far fewer tokens. A request with max_tokens set to 4,000 that returns 200 tokens still counts as 4,000 against the limit. That is how apps get 429s while their usage metrics look fine.
On Anthropic, cache repeated content such as system instructions. Cached input tokens do not count toward the input token limit, which turns a fixed system prompt from a cost into a discount.
Project-level limits are the simplest cost control of all. Give each project its own ceiling. A runaway script then hits its own wall instead of taking down production.
A practical rate-limit checklist
| Layer | What to do | Why it matters |
|---|---|---|
| Client | Honour Retry-After, back off with jitter, cap attempts | Stops retry storms from burning quota |
| SDK | Disable SDK retries when you add your own loop | Prevents multiplied attempts |
| Requests | Set max_tokens close to the expected answer | Stops unused token allowance from eating TPM |
| Quotas | Split limits per project and per feature | Contains a runaway script to one project |
| Traffic | Ramp up gradually, queue bursts | Avoids slow_down and acceleration limits |
| Users | Show a clear message when a request stalls | Users wait patiently when they know why |
Testing that your app survives a 429
Most apps are never tested against a real throttle. Three approaches cover the gap, and each finds different problems.
Mock the SDK client in your tests. This shows whether your error branch runs at all. It does not show the provider's real status codes or headers.
Intercept your app's real traffic and return the provider's own errors. Tools such as Microsoft's Dev Proxy do this with presets that fail most requests with the provider's real error bodies, including rate_limit_exceeded, slow_down and credit_balance_exhausted. Your app keeps calling the real URL, so the test covers the real code path.
Throttle on the tokens your app actually uses. Dev Proxy's language model rate limiting plugin counts the prompt and completion tokens each response reports and returns a 429 with retry-after when your app crosses the limits you set. That test shows whether your backoff and queueing hold under real token pressure.
Do not test by calling the real API until it throttles you. You pay for every token, and you cannot trigger a slow_down or spend cap on demand.
Bottom line
API rate limiting for LLM apps comes down to four habits. Know your quotas, including the difference between RPM and TPM. Read the 429 before retrying, because a billing error needs a person, not a loop. Back off exponentially with jitter and honour Retry-After. And shrink what counts against the limit by sizing max_tokens and caching what repeats.
Build those habits into one shared client or gateway, test them with intercepted errors, and a throttle becomes a slow day instead of an outage.