The first rate limiter most LLM products ship is the one they would have shipped in front of any API: so many requests per user per minute, enforced at the gateway, with a 429 when the count runs out. It is familiar, it is a few lines of configuration, and it protects the wrong thing.

The scarce resource behind an LLM feature is not your servers. It is a token quota you rent from a model provider, shared by every customer you have, and metered by a rule the provider sets and you do not. A limiter that counts requests lets the one account that sends 200-page documents spend everyone's quota, and blocks the user who asks twenty one-line questions. My position is that the edge limiter of an LLM product should be a reservation system for the provider's quota. It should charge each request what the provider will charge it at admission, keep a share for the people waiting on a screen, and queue the rest instead of rejecting it.

The view I am arguing against

It comes in two forms, and both are reasonable.

The first says a per-user request limit is enough, because the provider enforces its own limits behind it. The second goes further: the provider is the limiter. Send the request, catch the 429, back off with jitter and try again. That is what the providers' own documentation recommends, it needs no state at your edge, and for a small product it works.

It stops working for a reason that sits in one sentence of OpenAI's rate-limit guide: "Rate limits are defined at the organization level and at the project level, not user level." The provider's limiter cannot see your tenants. When the shared quota runs out, the 429 lands on whoever arrives next, which is rarely the account that spent it. The same guide adds that "unsuccessful requests contribute to your per-minute limit", so clients that retry into a full quota keep spending it while they fail. I have argued before that a retry is a purchase; a retry into someone else's congestion buys nothing at all.

What the provider actually counts

Before you can reserve a provider's quota, you need its meter. The three I read this week do not agree with each other.

ProviderWhat counts against the token limit at admissionDoes max_tokens count?Notes from the documentation
OpenAIThe larger of max_tokens and an estimate based on the request's character countYesLimits at organisation and project level; some model families share one limit
Azure OpenAIAn estimate that includes the prompt text, max_tokens and best_of, based in part on character count; not the billing countYesRequest rate is evaluated over short periods, "typically 1 or 10 seconds"
AnthropicInput tokens estimated at the start of the request and adjusted to the actual count; output counted as it is generatedNoToken bucket with continuous replenishment; for most models, cached reads do not count toward the input limit

Three things follow, and none of them is visible from your own code.

First, max_tokens is a quota setting on two of these and not on the third. Microsoft's quota page says it plainly: if you expect responses of about 200 tokens, do not set max_tokens to 4,000, because the rate-limit estimate includes it even when the answer is short. On Anthropic the documentation says the opposite, that max_tokens does not factor into the output limit. The same request, moved between providers, consumes a different amount of quota.

Second, on Anthropic, prompt caching is a rate-limit lever as well as a cost lever. Only uncached input counts toward the input limit for most models, so a long, stable system prompt that is cached stops crowding out your users' requests.

Third, the meters are estimates made from characters, not from your tokenizer. Your edge will disagree with the provider by some margin. Keep headroom, and correct from the provider's response headers (x-ratelimit-remaining-tokens on OpenAI, the anthropic-ratelimit-input-tokens-remaining family on Anthropic) rather than trusting your own arithmetic.

Why counting requests fails both ways

An illustrative example, with round numbers chosen to make the shape visible, not taken from any system.

Say your project has a quota of 500,000 tokens a minute. Two hundred people are using the interactive feature, each sending about one request a minute, and the provider counts roughly 2,000 tokens for each at admission. That is 400,000 tokens a minute, comfortably inside the quota. Your gateway allows 20 requests per user per minute.

Now one tenant starts a document job: five requests a minute, each carrying about 80,000 tokens of source text. Five requests a minute is a quarter of the per-user limit, so the gateway never notices. The job adds 400,000 tokens a minute, demand is now 800,000 against a quota of 500,000, and the provider starts returning 429s. Most of them go to the two hundred interactive users, because they send most of the requests.

Meanwhile a power user asking 25 short questions a minute, about 1,500 tokens each, is blocked by the same gateway. Their whole minute costs 37,500 tokens, under 8 per cent of the quota.

A request limiter under-protects and over-rejects on the same traffic. It is measuring the one dimension that does not track the cost.

A reservation, not a counter

What works is closer to a ledger than a turnstile.

Estimate the way the provider estimates. For each model ID you call, write down the provider's admission rule and implement it next to the model configuration: the larger of max_tokens and the estimate on OpenAI, an estimate built from the prompt, max_tokens and best_of on Azure, which is how its documentation describes it, uncached input on Anthropic with output handled separately. When you switch provider, the estimator changes with it.

Reserve before the call. Each request takes its estimate from a token bucket at the edge before it is sent. The bucket refills continuously at the quota's per-second rate. This is the answer to the token-bucket-or-sliding-window question, and it is not a matter of taste. Anthropic says its own limiter is a token bucket whose capacity "is continuously replenished up to your maximum limit", and both Azure and Anthropic warn that a per-minute limit may be enforced over seconds; Anthropic's example is 60 requests a minute enforced as one a second. A 60-second sliding window at your edge will happily admit a burst in the first five seconds that the provider then rejects. Keep the bucket's capacity to a few seconds of refill, so the largest burst you admit is one the provider will accept.

Reconcile after the call. Where the provider adjusts its count to actual usage, as Anthropic does for input, refund the difference to the bucket. Where the documentation does not say that it adjusts, do not assume a refund. Read the remaining-tokens header on every response and let it pull your ledger back into line.

Hold back headroom. Size the edge budget below the provider quota, so the disagreement between your estimate and theirs is absorbed by you rather than by a user.

Interactive (person waiting) and background (queued) lanes pass a box that estimates tokens as the provider counts. Background requests queue in per-tenant slots; interactive ones are rejected there, with a time. Both draw from a token bucket that refills continuously and keeps an interactive floor, feeding the provider quota shared by all tenants; the remaining-tokens header returns to reconcile. Interactive (person waiting) Background (queued) Estimate as the provider counts Reject here, with a time Refills continuously Interactive floor Provider quota (shared by all tenants) Remaining-tokens header: reconcile
Charge each request what the provider will count, keep a floor for the people waiting, and queue the rest.

Who waits, and who is told no

Once the edge knows what each request costs, the questions that matter are product questions, and they are the ones a request limiter never lets you ask.

Is a person waiting? Split traffic into two classes: interactive, where someone is looking at a screen, and background, where nobody is. Give the interactive class a floor, a share of the budget that background work can borrow while it is idle but cannot take while it is in use. Background work queues against the remainder and drains at whatever rate the budget allows. Nobody on a screen should ever lose a request to a document job.

How big can one request be? Cap the size of a single call below the bucket's capacity. A 200-page document becomes a sequence of section calls, each one reservable, each one able to wait its turn. Without the cap, one call can be larger than everything the bucket admits in a burst, and it either never gets in or it gets in by starving everyone.

How is one tenant kept from the rest? Inside the background class, give each tenant a weighted share and queue its work behind its own share, not behind the whole class. The account that sends 200-page documents waits longer. That is the correct outcome, and it should be in the contract, not discovered in a support ticket.

What does a rejection say? Only interactive requests should be rejected, and the rejection should come from your edge, which knows its own bucket and can say when capacity returns. Never pass a provider's 429 through to a user, and never let a client retry it in a tight loop. And not every 429 is congestion: Anthropic's documentation notes that the 429 for reaching your spend cap never carries a retry-after header. That is a billing state, not a traffic state. It should page a person, not trigger a retry.

What I got wrong

The first limiter I put in front of a model was a per-user request count, copied from the API gateway we already ran. The day it mattered, the account that caused the trouble never saw an error. A bulk job on one tenant's account stayed well under its request limit while it emptied the shared quota, and the 429s landed on people using the interactive features of other accounts. We had built a limiter that protected the provider's servers, which protect themselves, and nothing that protected our users from each other. The fix was the floor for interactive traffic, and it took a day. Finding out we needed it took a bad morning.

The decision for Monday

  1. For every model ID you call, write down what the provider counts at admission, with the documentation link and the date you read it.
  2. Where max_tokens counts toward the limit, lower it to what your responses actually need.
  3. Log tokens per minute per tenant at the edge for a week, and find the share of the quota your largest tenant takes at its peak.
  4. Mark every route as interactive or background, and give interactive traffic a floor.
  5. If you can ship only one thing this month, ship the cap on single-request size. It is a few lines, and it removes the worst case.

Where this is weakest

If your peak usage stays well inside the quota, all of this is overbuilt. My own rule of thumb, a judgement rather than a measurement, is that below about half the quota at peak, a request limit and honest backoff are enough, and the engineering time is better spent elsewhere.

There is also a partial alternative on the provider's side. Because OpenAI sets limits per project, you can give one or two very large tenants their own project and let the provider do the isolation. That is reasonable for two tenants. It does not scale to thousands of schools or customers, and it moves your fairness policy into an account structure that nobody reviews.

What would change my mind is providers offering per-end-customer sub-quotas, or priority classes a request can carry, set by the caller and enforced upstream. If the provider can tell my tenants apart and protect my interactive traffic, most of the ledger at the edge becomes a duplicate of theirs.

The short version

An LLM product rents a token quota that every customer shares and that the provider meters by its own rule. Do not limit requests at the edge. Reserve what the provider will count, from a token bucket that refills the way theirs does, and reconcile from their headers. Keep a floor for people who are waiting, queue the work nobody is watching, cap the size of a single call, and let the tenant that sends the largest documents be the one that waits.

None of this raises your quota. It decides who pays when you run out of it.

Illustrations generated with AI.