Skip to content

Rate limiting for LLM APIs: tokens per minute, not requests

Rate limiting caps how fast a caller can use an API. Why LLM rate limits are counted in tokens, how 429s and retry-after work, and how to set per-team limits.

Published
Reading time
16 min read

In short

  • Rate limiting caps how much a caller can use an API in a period of time. LLM providers count tokens as well as requests, because one request can carry fifty tokens or two hundred thousand.
  • Anthropic limits requests, input tokens, and output tokens per minute separately, with a token bucket that refills continuously. OpenAI limits requests and tokens per minute and per day, and counts the larger of max_tokens and its own estimate against the limit.
  • A 429 is not one error. A rate limit, a ramp limit, and a spend cap can all return it, and only the body tells you which. Wait at least the retry-after value, and never retry a spend cap.
  • Provider limits belong to the whole organization. Per-team and per-key limits that you set at a gateway keep one busy caller from pushing every other caller into 429s.

Rate limiting is a cap on how much a caller can use an API in a given period, enforced by rejecting or delaying requests over the cap. Most APIs count requests. LLM APIs also count tokens, because one call can carry fifty tokens or two hundred thousand, and the provider's cost follows the tokens.

That one difference changes how you size limits, how you estimate a call before sending it, and how you read a 429. The provider mechanics below are from the Anthropic and OpenAI rate limit guides as of November 2026.

What is rate limiting

Rate limiting is a server-side rule that allows a caller a fixed amount of work per time window and rejects the excess, usually with HTTP 429 Too Many Requests. It protects shared capacity from one heavy caller, bounds the cost of a leaked key, and keeps latency stable for everyone else.

A rate limit has three parts:

  • A key: what is counted, such as an API key, an organization, a project, or an IP address.
  • A unit and a window: what is counted and over how long, such as 1,000 requests per minute.
  • A response to the excess: reject with 429, queue the request, or slow it down.

RFC 6585 defines 429 as the status for a user who has sent too many requests in a given amount of time, and allows the response to include a Retry-After header saying how long to wait. Everything else, including which unit is counted and how the window moves, is up to the API.

API rate limits are the published version of those rules for a given service: the units, windows, and numbers a caller can plan around.

Why LLM API rate limits are counted in tokens

LLM API rate limits count tokens because tokens, not requests, are what consume the provider's GPUs. A request limit alone would let a caller send a few hundred very long prompts and use more capacity than thousands of short ones.

Anthropic's numbers show the gap. On the Start tier, Claude Sonnet 5.5 allows 4,000 requests per minute and 2,000,000 input tokens per minute. Those two limits meet at 500 uncached input tokens per request. A RAG application that sends 20,000-token prompts reaches the input token limit at 100 requests per minute, 2.5% of its request limit.

For most LLM workloads the token limit is the one you hit. Size capacity in tokens per minute and treat the request limit as a ceiling for workloads of many short calls, such as classification or embeddings.

The limits LLM providers enforce

Both major providers enforce several limits at once, and a call has to fit inside every one of them. The table compares the dimensions, not the numbers, which vary by model and tier.

LimitAnthropicOpenAI
Requests per minuteRPM, per model classRPM, plus requests per day (RPD)
Tokens per minuteInput (ITPM) and output (OTPM), separatelyTPM, plus tokens per day (TPD)
Cached inputCache reads do not count toward ITPMNot stated in the rate limit guide
How output is countedActual tokens, as they are generatedThe larger of max_tokens and an estimate from the request's characters
Growth limitRamp limit, ramp_limit_exceededslow_down when traffic rises too quickly
ScopeOrganization, with optional lower workspace limitsOrganization and project
Shared poolsSome model families share one limitSome model families share one limit
BatchSeparate limits, not subject to ramp limitsSeparate queue limit on input tokens

Three rows change how you engineer around the limits.

Input and output are separate on Anthropic. A summarization job with long inputs and short outputs runs out of ITPM long before OTPM. A generation job does the reverse. Track both, because the headroom you have on one says nothing about the other.

Cache reads are free against Anthropic's ITPM. Only input_tokens and cache_creation_input_tokens count. Anthropic's own example: with a 2,000,000 ITPM limit and an 80% cache hit rate, an organization can process 10,000,000 input tokens a minute. Prompt caching is a cost optimization and a throughput one.

Ramp limits fire under the rate limit. Anthropic caps how fast an organization's usage on a model can grow, at its recent peak plus a step per minute, and a burst within a few seconds can count. OpenAI returns slow_down for the same pattern and suggests that above 1 million input tokens per minute you raise traffic by no more than 50% every 15 minutes. A batch job that starts at full speed, or a failover that moves all traffic at once, hits these limits first.

Provider tiers and how limits grow

Provider limits rise with account history, not on request alone. Both providers place an organization on a usage tier and raise it automatically.

Anthropic places organizations on Start, Build, Scale, or Custom tiers based on usage history and account standing, and new organizations can start on a lower Evaluation tier. Each of Start, Build, and Scale carries a monthly spend cap. OpenAI moves an organization up its tiers as total credit purchases cross published thresholds, and each tier has its own per-model limits and monthly usage limit.

Two practical consequences:

  • A new account is a small account. A production launch on an organization created last week will run on the lowest limits. Create the production organization early and build history on it.
  • Tier limits are maximums, not guarantees. Anthropic's guide states that limits represent maximum allowed usage, not guaranteed minimums. Overload errors (529 on Anthropic, 503 on OpenAI) can arrive while you are well under every limit, and they need the handling described in LLM failover, not a lower rate.

Token bucket, fixed window, and sliding window

A rate limiter decides when used capacity comes back. The three common algorithms differ in how they treat bursts at the edge of a window.

AlgorithmHow capacity returnsBurst behavior
Fixed windowAll at once, at the start of each windowUp to twice the limit across a window boundary
Sliding windowContinuously, as old requests leave a trailing windowNo boundary burst. Needs a log or a weighted pair of counters
Token bucketContinuously, at a fixed refill rate, up to a capacityA full bucket can be spent at once, then the rate is the refill rate

A fixed window counter resets at, say, the top of each minute. A caller can spend the whole limit in the last second of one minute and again in the first second of the next.

A sliding window counts usage over the trailing 60 seconds at every moment. The exact version keeps a log of timestamps. The cheaper version weights the previous fixed window's count by how much of it still overlaps the trailing window.

A token bucket holds up to a set capacity of tokens and refills at a fixed rate. Each request removes what it costs. If the bucket is short, the request waits or is rejected. Anthropic states that its API uses a token bucket, so capacity is replenished continuously instead of resetting at fixed intervals.

EVERY BUCKET MUST COVER THE CALLRESULTRequest42K INPUT TOKENSMAX_TOKENS 4,096Requests per minutePASSAVAILABLE 2,480 · NEEDS 1Input tokens per minuteSHORT 14KAVAILABLE 28K · NEEDS 42KOutput tokens per minutePASSAVAILABLE 70K · NEEDS ~4K429RATE_LIMIT_ERRORRETRY-AFTER: 9
A call must fit every bucket at once. Requests and output tokens have room, but the input bucket is 14K tokens short, so the call gets a 429 with retry-after set to the time that bucket needs to refill. The numbers are illustrative.

The bucket explains a behavior that surprises teams. Anthropic notes that a limit of 60 requests per minute might be enforced as 1 request per second, so a short burst can trigger 429 errors while the per-minute total is well under the limit. Spread requests evenly instead of sending a minute's work in the first few seconds.

Estimate tokens before the call

A client-side limiter needs to know what a call will cost before it sends it. Input tokens can be counted. Output tokens can only be bounded.

For input, Anthropic offers a token counting endpoint, /v1/messages/count_tokens, that accepts the same system prompt, messages, tools, images, and PDFs as a real call. It is free, its rate limits are separate from message creation, and its result is an estimate that can differ slightly from the final count. Count against the model you will call: Anthropic notes that Claude Opus 4.7 and later models use a tokenizer that produces roughly 30% more tokens for the same text than earlier models.

For output, the providers differ, and the difference matters:

  • OpenAI counts the larger of max_tokens and its own estimate from the request's character count toward your limit. A request with max_tokens set far above what it needs spends limit it never uses. Set max_tokens close to the expected response size.
  • Anthropic evaluates OTPM in real time as tokens are generated and does not count max_tokens. It also estimates ITPM at the start of a request and adjusts it to the actual count during the request.

A client-side limiter can follow the same pattern: charge an estimate before the call and settle the difference once the response reports real usage.

token-bucket.ts
/** Refills continuously, the way the provider's limiter does. */
export class TokenBucket {
  private level: number;
  private last = Date.now();
 
  constructor(private capacity: number, private perMinute: number) {
    this.level = capacity;
  }
 
  private refill() {
    const now = Date.now();
    const added = ((now - this.last) / 60_000) * this.perMinute;
    this.level = Math.min(this.capacity, this.level + added);
    this.last = now;
  }
 
  /** Milliseconds to wait before `cost` is available. 0 means it was taken. */
  take(cost: number): number {
    this.refill();
    if (this.level >= cost) {
      this.level -= cost;
      return 0;
    }
    return ((cost - this.level) / this.perMinute) * 60_000;
  }
 
  /** Once usage is known, return the overestimate or charge the shortfall. */
  settle(estimated: number, actual: number) {
    this.refill();
    this.level = Math.min(this.capacity, this.level + estimated - actual);
  }
}

For an Anthropic ITPM bucket, settle with input_tokens + cache_creation_input_tokens from the response's usage, since cache reads do not count. Set the capacity below the provider's limit, because other processes on the same organization draw from the same allowance and your local bucket cannot see them. A request whose cost exceeds the bucket's capacity will never pass, so reject it with a clear error before it waits forever.

Concurrency: the limit you set yourself

A concurrency limit caps how many requests are in flight at once. Neither provider's rate limit guide lists one for standard model calls, but you need one anyway, because LLM calls are slow and a request rate alone does not bound how much is outstanding.

Little's law gives the relationship: requests in flight equal the arrival rate times the average duration. At 5 requests per second and 20-second responses, 100 requests are in flight. If a provider slows down and responses take 60 seconds, the same traffic holds 300, along with their connections, memory, and the tokens they are still generating.

Concurrency limits do three things a per-minute limit cannot:

  • They bound the damage of a slowdown, because new work queues instead of piling onto a struggling provider.
  • They narrow the budget overshoot described in virtual keys, where every request in flight passed the same balance check.
  • They give an agent loop that fans out tool calls and sub-agents a ceiling, so one run cannot claim the whole allowance.

Set concurrency per caller, and size it from the token limit: the allowed in-flight count is roughly the tokens-per-minute share divided by the tokens per call, times the average duration in minutes.

How to handle a 429 and retry-after

Handle a 429 by reading the body first, because several different conditions share the status. Then wait at least the retry-after value plus a small random delay, or move the request to capacity elsewhere.

On Anthropic, the error type is rate_limit_error for all three of these, and error.details.error_code separates them:

ConditionHow to recognize itWhat to do
Rate limitretry-after header presentWait the stated seconds, then retry
Ramp limiterror_code: "ramp_limit_exceeded"Wait, then grow traffic by at most one step per minute
Spend caperror_code: "enforced_spend_limit_reached", no retry-afterDo not retry. Access resumes next month or after a tier change

On OpenAI, a 429 can be a rate limit, a slow_down for traffic that rose too quickly, or a hard spend limit. The guide says not to retry quota, billing, or other errors that need someone to take action.

Four rules keep retries from making the limit worse:

  1. Treat retry-after as a floor. Anthropic warns that earlier retries might fail, and OpenAI says to treat the value as a minimum and add a small random delay. Without the header, use exponential backoff with jitter.
  2. Parse both formats. RFC 9110 allows Retry-After to be a number of seconds or an HTTP date. Both providers document seconds, but a proxy in between may send either.
  3. Failed requests still count. OpenAI's guide notes that unsuccessful requests contribute to the per-minute limit, so an immediate resend spends limit and gets the same answer.
  4. Retry in one layer. OpenAI advises that if you manage retries yourself, you disable SDK retries or count them in your limits. An SDK, a gateway, and an agent framework that each retry three times turn one 429 into many.
retry-after.ts
/** Milliseconds to wait from a Retry-After value, or undefined if absent. */
export function retryAfterMs(header: string | null): number | undefined {
  if (!header) return undefined;
  const seconds = Number(header);
  if (Number.isFinite(seconds)) return Math.max(0, seconds * 1000);
  const date = Date.parse(header); // the HTTP-date form
  return Number.isNaN(date) ? undefined : Math.max(0, date - Date.now());
}

If the wait is longer than the caller's deadline, do not sleep through it. Send the request to another key on another account, or to another provider, as covered in LLM failover, or return the error.

Read the rate limit headers before you hit the limit

Both providers return headers that report your limit, what remains, and when it resets. Reading them lets a client slow down before the 429, instead of after.

What it reportsAnthropicOpenAI
Requestsanthropic-ratelimit-requests-limit, -remaining, -resetx-ratelimit-limit-requests, x-ratelimit-remaining-requests, x-ratelimit-reset-requests
Tokensanthropic-ratelimit-tokens-*, plus -input-tokens-* and -output-tokens-*x-ratelimit-limit-tokens, x-ratelimit-remaining-tokens, x-ratelimit-reset-tokens
Narrower scopeThe tokens headers show the most restrictive limit in effect, such as a workspace limitx-ratelimit-*-project-tokens when a project token limit applies
Reset formatRFC 3339 timestampA duration, such as 6m0s
Wait after a 429retry-after, in secondsRetry-After, in seconds

Two details trip up parsers. Anthropic rounds remaining token counts to the nearest thousand, so a small remaining value is approximate. And the two providers express reset differently, one as a point in time and one as a duration, so a shared client needs a parser for each.

A simple use: when remaining tokens fall below the size of the next request, wait until the reset time before sending, rather than sending and parsing a 429.

Per-team and per-key rate limits at a gateway

Provider limits apply to the whole organization, so every application on one account competes for one allowance. Per-team and per-key limits split that allowance so that one caller's burst cannot push the others into 429 errors.

The provider gives you one level of this. Anthropic lets you set lower spend and rate limits per workspace, for each limiter type. Its example: an organization with 40,000 input tokens per minute can cap one workspace at 30,000, leaving the rest for other workspaces. Organization limits still apply even if workspace limits add up to more. OpenAI sets limits at the organization and project levels.

A gateway adds the levels the provider does not have: one limit per application, per environment, per team, and per customer, across every provider behind it. Each caller holds a gateway-issued virtual key instead of a provider key, and the gateway checks the key's limits before forwarding.

Bifrost, an open-source AI gateway by Maxim AI, is a concrete example. Its rate limits can be set on a provider config inside a virtual key, on the virtual key, on a team, and on a customer, and a request must pass both a request limit and a token limit at every level that has one. Token limits count prompt and completion tokens together. Reset windows include 1m, 1h, and 1d.

create-virtual-key.sh
curl -X POST http://localhost:8080/api/governance/virtual-keys \
  -H "Content-Type: application/json" \
  -d '{
    "name": "support-bot-prod",
    "team_id": "team-support",
    "provider_configs": [
      {
        "provider": "anthropic",
        "allowed_models": ["*"],
        "key_ids": ["*"],
        "rate_limit": {
          "token_max_limit": 500000,
          "token_reset_duration": "1m",
          "request_max_limit": 300,
          "request_reset_duration": "1m"
        }
      },
      {
        "provider": "openai",
        "allowed_models": ["*"],
        "key_ids": ["*"],
        "rate_limit": {
          "token_max_limit": 250000,
          "token_reset_duration": "1m"
        }
      }
    ],
    "rate_limit": {
      "token_max_limit": 600000,
      "token_reset_duration": "1m",
      "request_max_limit": 400,
      "request_reset_duration": "1m"
    }
  }'

When a provider config inside a key runs past its limit, Bifrost excludes that provider from routing for the key, and the other providers on the same key stay available. When the key itself is over its limit, the caller gets a 429 with an error type of token_limited or request_limited for the dimension that ran out. Budgets are a separate check that returns 402 with budget_exceeded, so a client's retry logic can tell a rate limit from an exhausted budget.

One sizing detail applies to any gateway that counts prompt and completion tokens together. Anthropic counts input and output separately and leaves cache reads out of ITPM, so a combined gateway limit throttles a long-prompt or well-cached workload earlier than the provider would. Set gateway token limits from observed usage per key, not by copying the provider's ITPM figure.

How to size the limits

Size per-key limits from what each caller has used, and keep their sum below the provider's limit with headroom for the callers that matter most.

A sequence that works:

  1. Route every caller through its own key with no limits, and record input, output, and cached tokens per minute for two to four weeks.
  2. Set each key's token limit at about twice its observed peak minute, and a concurrency limit to match.
  3. Check the sum against the provider's limit for each model. If the sum exceeds it, the keys can still collide at the provider, so lower the limits on batch and internal tools first.
  4. Move bulk and offline work to the providers' batch APIs, which have separate limits and, on Anthropic, are not subject to ramp limits.
  5. Request a higher tier before a launch, not during one.

Revisit limits when a key changes model. A model with a new tokenizer, or a switch from a cached to an uncached prompt layout, changes token counts without changing a line of application code. LLM cost optimization covers the levers that reduce tokens per request, which raise effective throughput under the same limits.

What to monitor

Monitor headroom, not only errors, because a 429 rate is a lagging signal.

  • Peak tokens per minute against the limit, per model, and for Anthropic separately for input and output. Anthropic's console charts the hourly maximum uncached input tokens per minute next to the limit and the cache rate.
  • 429 responses by kind: rate limit, ramp limit, and spend cap, from the error body, per key.
  • Time spent waiting, in client-side buckets and in retry-after sleeps. A rising wait is the first sign that a key needs a higher limit.
  • Requests in flight per key and per provider, against the concurrency limit.
  • Cache hit rate, since on Anthropic it raises effective ITPM directly.

When the wait time grows, the choices are a higher limit for that key, a higher provider tier, fewer tokens per request, or work moved to batch. A gateway log that records tokens and the key on every request answers which.

Frequently asked questions

What is rate limiting?

Rate limiting is a rule that caps how many requests, or how much work, a caller can send to an API in a period of time. Requests over the cap are rejected, usually with HTTP 429 Too Many Requests, or delayed until capacity returns. It protects shared capacity, bounds the cost of a leaked key, and keeps latency predictable for other callers.

What are API rate limits for LLMs?

LLM API rate limits cap requests and tokens per minute, and sometimes per day, for each model. Anthropic limits requests, input tokens, and output tokens per minute separately. OpenAI limits requests and tokens per minute and per day. Both raise limits automatically as an organization moves up usage tiers, and both apply limits at the organization level.

What does tokens per minute (TPM) mean?

Tokens per minute is the number of tokens a caller can send and receive in one minute. On OpenAI, the larger of max_tokens and an estimate of the request counts against it. On Anthropic, input and output tokens have separate limits, output is counted as it is generated, and input tokens read from the prompt cache do not count.

Why do I get a 429 error when I am under my rate limit?

A 429 under the per-minute limit usually comes from a burst or a ramp limit. Anthropic's token bucket may enforce 60 requests per minute as one per second, and both providers reject traffic that grows too quickly. A 429 can also mean a monthly spend cap was reached. Check the error body to see which one it is.

What is the difference between a token bucket and a sliding window?

A token bucket refills capacity at a fixed rate up to a maximum, so a full bucket allows one burst, after which requests are limited to the refill rate. A sliding window counts usage over the trailing period at every moment, which prevents bursts across window boundaries but needs a timestamp log or weighted counters. Anthropic's API uses a token bucket.

How do you rate limit LLM usage per team?

Issue each team or application its own key at a gateway and set request, token, and concurrency limits on it, with the sum kept below the provider account's limit. Anthropic workspaces offer one provider-side level of this. A gateway such as Bifrost adds limits per provider, key, team, and customer across every provider it routes to.

Sources

  1. 01Rate limitsClaude API docs
  2. 02Token countingClaude API docs
  3. 03ErrorsClaude API docs
  4. 04Rate limitsOpenAI API docs
  5. 05Error codesOpenAI API docs
  6. 06RFC 6585: Additional HTTP Status Codes (429 Too Many Requests)IETF
  7. 07RFC 9110: HTTP Semantics (Retry-After)IETF
  8. 08Token bucketWikipedia
  9. 09Budget and limitsBifrost docs
  10. 10Virtual keysBifrost docs