Guide

LLM rate limiting: how to stop one script from blocking everyone

Provider rate limits protect the provider, not your team. How to set your own limits on requests and tokens per person or app, and what a good 429 looks like.

LLM rate limiting means capping how many requests or tokens each person, key or app can send in a period of time. Providers already limit your account, but those limits protect the provider, not your team: one runaway script can use the whole account's quota and block everyone else. Your own limits, set per key or per person in a gateway, stop that from happening.

Updated 3 December 2026.

Two layers of limits

LayerWho sets itWhat it protectsTypical unit
Provider limitsOpenAI, Anthropic, Groq and othersThe provider's capacityRequests and tokens per minute, per account or project
Your limitsYou, in a gatewayYour team's share and your budgetRequests per minute per key; tokens per day or month per person

When every app shares one provider key, the provider's limit is a shared pool. The first script to hit it takes everyone down with a burst of 429 errors. That's why your own layer matters.

What to limit

There are three useful kinds of limit, and you'll usually want more than one:

  1. Requests per minute (RPM) per key. Stops loops and runaway scripts. Cheap to enforce and easy to explain.
  2. Tokens per day or month per person. Controls cost, because long prompts and long answers are what you pay for.
  3. Allowed models per person. Keeps the most expensive models for the people who need them.

Some gateways also offer tokens per minute (TPM) limits, which smooth out heavy bursts. Databricks' gateway, for example, supports queries-per-minute and tokens-per-minute limits per endpoint, user or group (Databricks docs). More on Databricks' gateway in Databricks AI Gateway alternatives.

What a good limit response looks like

When a limit is hit, the caller should get an answer it can act on, not a silent failure or a timeout:

  • HTTP status 429 for rate and budget limits.
  • A message that says which limit was hit.
  • Headers that say how much is left and when it resets.

For example, AI Gateway by LayerX returns 429 rate_limit_exceeded with x-ratelimit-remaining-requests and x-ratelimit-reset-requests when a key goes over its requests per minute, and 429 budget_exceeded with x-budget-reset when a person's daily token budget is used up (product page). Well-behaved clients read those headers and back off.

Vercel AI Gateway takes a different approach for budgets: once a budget is exceeded, it rejects requests in that budget's scope with HTTP 402 (Vercel docs).

Where to enforce limits

OptionPer personAcross providersEnforced before spend
Provider dashboardsNo, per account or projectNoOnly the provider's own limits
In each app's codeIf every app does itWith workOnly in that app
A gatewayYesYesYes

A gateway is the only place that sees every request from every app, whichever provider serves it, including your own GPUs. More in what is an LLM gateway.

Gateways that do this

  • LiteLLM sets budgets and rate limits per key, user and team in its open-source proxy (LiteLLM).
  • Kong AI Gateway offers advanced AI rate limiting and token budgets per consumer group (Kong docs).
  • Agent Router (formerly Envoy AI Gateway) sets token limits per team, app or model (Agent Router).
  • AI Gateway by LayerX gives every key a requests-per-minute limit and every person daily and monthly token budgets and a list of allowed models, across your own GPUs and vendors.

Rate limits on your own GPUs

Self-hosted models need limits too, for a different reason: capacity, not money. A single heavy user can saturate a vLLM server and slow everyone else down. A gateway that respects per-server concurrency limits and moves overflow to another server or a vendor keeps response times steady. See use your GPUs first.

Questions

What is the difference between RPM and TPM limits?

RPM counts requests per minute. TPM counts tokens per minute. RPM stops loops; TPM and token budgets control cost and load from long prompts.

How do I rate limit OpenAI usage per user?

Provider limits apply to your account, not to the people using it. To limit each person, give everyone their own key from a gateway and set per-key and per-person limits there.

What should happen when a user hits a limit?

They should get HTTP 429 with a clear message and headers showing when the limit resets, so their app can wait and retry.

Do I need rate limits if I only use my own GPUs?

Yes, to protect capacity. One heavy user can slow a shared server for everyone.

More posts

Keep reading.

See how AI Gateway fits your setup.

Tell us what you run today and how many people need access. We'll get back to you to learn more about your setup.

See how AI Gateway fits your setup.

What do you run today?