← Blog
Ceramic capsules of different sizes pass through an orange gate into two shared channels.
Published on
2025-10-03

LLM rate limiting and quotas: tokens and concurrency

LLM rate limiting controls how quickly applications can send requests or consume tokens. A quota defines an allowance over a stated period, such as a daily token budget. For shared inference, combine these controls with concurrency limits and admission control: request rates measure arrivals, token quotas constrain usage, and admission checks decide whether the serving pool can accept more work now.

A short classification request and a long document analysis can each count as one API call while placing different demands on the same model. A request counter alone cannot represent that difference. Token limits add useful information, but they still need a defined time window, accounting method, and identity scope.

This guide is for platform teams and developers operating large language models on shared infrastructure. It explains how to choose LLM rate limiting controls, handle rejections, and check tenant isolation in Hivenet Router. The original documentation review was completed on November 11, 2026; occupancy admission, queue, and multi-router guidance was checked against the v0.1.7 admission-control reference on November 16, 2026. The model-access guidance was checked against Router v0.1.8 on December 1, 2026, and daily token accounting against v0.1.9 on December 3, 2026. Router is currently in alpha. The capacity example is arithmetic, not a deployment benchmark or a recommended production configuration. For the broader relationship between admission, model selection, and backend selection, see the LLM routing guide.

LLM rate limits: requests, tokens, and concurrency

Start by naming the failure you want to prevent. A single user sending unbounded work can consume resources needed by other users. Rate limits help protect infrastructure by restricting arrivals and token consumption; concurrency and occupancy checks address work that is already running. An application that sends too many small requests needs a different control from one that holds several long generations open. A daily usage allowance addresses a third problem: how much a tenant may consume over a longer period.

ControlWhat it measuresWhat it does not establish
Requests per minute (RPM)How many requests may enter over time, subject to burst rules.The token count or resource demand of each request.
Input tokens per minute (ITPM)The rate of admitted prompt-token consumption.How much output those requests will generate.
Output tokens per minute (OTPM)Generated token usage over time, according to the limiter's accounting rules.A live tokens-per-second ceiling or automatic stream cutoff.
Daily token budgetA longer-period allowance for token usage.A monetary spending cap or an exact reservation of GPU capacity.
Concurrency limitThe maximum number of in-flight requests.Equal resource demand across concurrent requests.
Token-weighted occupancyThe estimated token footprint of work currently admitted.An exact measurement of physical KV-cache memory.
Per-request input or image capThe size of an individual incoming request.A rate limit across multiple requests.

These definitions are separate from implementation details. A gateway may estimate tokens before forwarding, account for actual usage afterward, or combine both. For example, Azure API Management documents estimation and concurrency effects that can let concurrent requests temporarily exceed a configured token limit. Check when your chosen system charges usage before treating its quota as a hard boundary.

How a token bucket rate limiter handles bursts

A token bucket refills permission to send work at a configured rate, up to a maximum capacity. Here, “token” describes the algorithm's accounting unit; it may represent a request rather than a language-model token. A full bucket permits a short burst. Once it drains, work cannot pass the limiter until enough capacity refills. Whether the caller waits in a queue or receives a rejection depends on the implementation; the bucket itself does not provide a queue.

Hivenet Router's RPM limiter uses this approach. With 60 RPM and the default full-minute burst capacity, an idle bucket can admit up to 60 requests before subsequent checks depend on refilling. It does not reset at the start of every wall-clock minute. That burst can still overload a small inference pool, so RPM limits should work alongside occupancy and concurrency checks.

Router's HIVENET_ROUTER_RPM_BURST_SECONDS setting can reduce the burst allowance. Values from 1 through 59 set it to that many seconds of the effective request rate, rounded down with a minimum capacity of one request; the default 0 retains the full-minute allowance. See the authentication and quota reference.

For LLM applications, pace calls before sending them and bound the number running concurrently. Client pacing reduces avoidable failed requests. Gateway enforcement remains necessary when multiple users or applications share the same infrastructure.

How Hivenet Router admits concurrent requests

Router applies generation admission gates to POST /v1/chat/completions and POST /v1/messages before work enters the routing queue or reaches a backend. After authentication and RPM admission, it checks per-request caps, pool pressure, pool occupancy and request count, serverless key limits, and the daily token budget.

The embeddings endpoint and the reranking endpoint skip the per-request token caps and KV-cache occupancy checks used for generation. Both still count toward request-rate limits, daily token budgets, and any configured serverless input-token rate limit. The messages token-counting endpoint counts toward RPM and skips daily token charging and generation admission checks.

Estimate the work entering the pool

The occupancy footprint starts with estimated input tokens plus declared maximum output. Router prefers max_completion_tokens, then max_tokens. Without a declared output maximum, it initially reserves input only and increases occupancy as output streams. It adjusts input accounting when exact usage becomes available and releases reservations when work completes, fails, times out, or disconnects.

A realistic output maximum therefore helps admission decisions, but an unnecessarily large value can make a request harder to admit. Prompt text, tool definitions, and message overhead also affect the estimate. This is a policy budget that needs calibration against your models and traffic; it is not a direct reading of free GPU memory.

The max_input_tokens check has another boundary: the reviewed implementation rejects when its learned estimate exceeds 1.5 times the configured value. The backend still enforces its actual context limit. Treat this Router setting as an early rejection check, not an exact tokenizer-based context guarantee.

A worked capacity example

Suppose a model has two healthy replicas, admit_budget_tokens: 64000 per replica, and max_inflight: 8 per replica. With Router's default admission fraction of 0.90, the effective occupancy budget is:

0.90 × 64,000 × 2 = 115,200 token units

The request-count backstop is 8 × 2 = 16 concurrent requests. If each request reserves 12,000 input tokens plus 4,000 output tokens, seven requests occupy 112,000 units. An eighth would bring occupancy to 128,000, exceeding the token budget even though the count remains below 16.

This example assumes no other gate binds and no existing reservation changes during the calculation. It shows why counting requests and weighting their size produce different decisions. It does not predict token throughput, latency, or the number of requests your hardware can serve. Test representative prompt lengths, output lengths, and mixed traffic before choosing these values.

An explicit admit_budget_tokens overrides the engine-derived token budget. If that setting is absent, v0.1.7 can derive a token budget from healthy vLLM or SGLang replicas’ reported KV capacity, applying the default admission fraction of 0.90. Without a token budget or an explicit max_inflight, admission uses eight requests per healthy replica. Upgrade agents before routers so the reports are available; older agents can leave the Router using that request-count fallback.

When the pool budget or request-count limit is full, Router can wait in a per-model admission queue. --admission-queue-depth controls its depth and defaults to --queue-depth, normally 30. Queue waiting is bounded by half of --request-timeout, within the overall request deadline: the default 60-second timeout allows at most 30 seconds of admission-queue waiting.

If no admission-queue slot is available, a separate short park controlled by HIVENET_ROUTER_ADMIT_PARK_TIMEOUT defaults to 250 milliseconds. If capacity remains unavailable when the applicable wait ends, Router returns 429 concurrency_limit_exceeded with Retry-After: 1. Admission rejection occurs before routing and does not trigger fallback. Setting --admission-queue-depth 0 leaves the short park enabled; set the park timeout to zero as well to remove occupancy waiting. Wake-from-zero handling has separate behavior. See the v0.1.7 admission-control reference.

Router can also reject requests through shed_if rules using reported engine pressure, such as KV-cache utilization or waiting requests. Missing signals pass the corresponding check. Confirm that your inference engines actually supply the metrics on which a policy depends.

Set token rate limits at the right tenant and model scope

With Router’s flat quota, each API key has its own requests-per-minute limit and daily token allowance. Two keys with the same owner can each spend their allowance. To cap what the customer can spend across both keys, set quota.tenant_tokens_per_day for that owner. The owner is metadata.owner on static keys and owner on dynamic keys. See the API key reference.

With quota.per_model, list each model the key may call. Its request rate scales with the number of healthy replicas, while its daily token allowance stays fixed. If the key also has an explicit model allowlist, the requested model must appear in both lists. For a model missing from a required list, Router returns 403 model_forbidden before charging quota. The flat fields for input and output tokens per minute cannot be combined with quota.per_model. The owner-wide tenant_tokens_per_day field works with either quota shape.

Serverless token rates and occupancy shares

For generation requests with mode: serverless, Router adds input and output token-rate controls plus max_occupancy_share. Input tokens are charged from the estimate before the daily budget check. Output tokens are charged after a local response finishes; a depleted output bucket rejects a subsequent request. It does not stop the current response at an instantaneous decode rate.

A key's occupancy share is its fraction of the replica-scaled admission budget, without the global 0.90 admission fraction. The global pool check still applies. Shares may add up to more than one, so they are caps on participation in a shared pool, not guaranteed reservations or priority for critical workloads. These extra controls do not run in reserved mode; a value of zero disables an individual limit.

If a customer needs its own serving capacity, you can reserve dedicated LLM replicas for that customer in Router v0.1.8. Use the two-key test to verify which pool handles each request.

Router v0.1.8 tracks serverless token-rate and occupancy limits separately for each key. Dynamic keys use their registry ID. Static keys use a stable identifier derived from the stored key hash. Two static keys owned by the same customer therefore have separate serverless counters.

Daily token budgets and budget control

In Router v0.1.9, chat, embeddings, and reranking draw from the same configured daily token budgets. With a flat quota, tokens_per_day covers one key across models. If tenant_tokens_per_day is set, the same usage also counts toward the owner’s allowance across keys. Both budgets reset at midnight UTC.

Before forwarding a chat request, Router holds the estimated input plus any requested maximum output. Other requests see that amount as reserved. After a local response, Router releases the hold and charges prompt and completion usage, estimating missing counts when needed. Final accounting cannot retract output the client has already received on a stream. See the v0.1.9 chat accounting rules.

For embeddings and reranking, only input tokens count. Router holds the input estimate before forwarding. If it exceeds either remaining budget, Router returns 429 token_limit_exceeded and charges neither budget. After success, Router charges the input token count the backend reports. If the backend supplies no token count, as with Infinity’s character counts, Router uses its estimate. A successful response that spends the remaining balance is still delivered.

How do two API keys share one customer’s daily budget?

Suppose a customer uses one key for chat and a batch key for embedding and reranking requests. Give both the same owner. Set quota.tokens_per_day to 6,000 for chat and 8,000 for batch. Set quota.tenant_tokens_per_day to 10,000 on both entries. Each request must fit both its key’s remaining allowance and the owner’s remaining allowance. With several Router instances, configure shared counters to enforce that budget across the site. See the tenant daily budget reference.

  • The chat key runs out first. If chat has used 6,000 tokens and batch has used 1,000, the owner has 3,000 left. The next chat request that needs tokens receives 429 token_limit_exceeded. Batch can still use the remaining 3,000 if its requests pass the other admission checks.
  • The owner then runs out. Once batch uses those 3,000 tokens, it has spent 4,000 of its own 8,000. Its next request also receives 429 token_limit_exceeded, even with 4,000 left on the key. Here the response message identifies the organization’s daily budget as exhausted. Both keys must wait for the midnight UTC reset unless the operator raises the relevant limits.

These figures illustrate completed, accounted usage with no overlapping requests. For a budget check before dispatch, a refusal charges neither budget. The X-RateLimit-Remaining-Tokens header reports the tighter remaining allowance. Even a positive balance can be too small for the input estimate on an embedding or reranking request, or for the estimated input plus requested maximum output on a chat request.

During key rotation, give the replacement key the same owner and tenant cap before retiring the old key. If keys for one owner specify different positive tenant caps, the lowest applies to all of them. Removing the only key that declares the cap can remove the owner-wide limit while another key is still active.

Token budgets can support usage allocation, but they do not establish a dollar budget. Budget control needs both the number of tokens charged and the cost of serving them. Model prices, fixed infrastructure cost, and external-provider billing need separate accounting. Multimodal admission estimates also have limits. Provider fallback retains pre-routing input charges, but provider output does not charge the local output-token-per-minute bucket or receive the usual daily output deduction. Reconcile usage and billing across both paths if you enable fallback.

Share limits across Router instances

In v0.1.7, several routers share rate and daily-token accounting and occupancy coordination only when configured with --sync-store=valkey. Without a shared store, each router enforces its limits independently; spreading one key’s traffic across three routers can allow up to three times its configured allowance. The v0.1.7 multi-router reference describes the supported setup.

Use a common --sync-site, a stable --router-id for each router, and --sync-min-routers set to the number of routers you run. Every agent must reach every router, using explicit --routers addresses or configured discovery. Deploy matching authentication, policies, and key registries to each router. Dynamic keys, policies, request queues, and model-alias pins are not replicated by the shared-limit mechanism.

Rate usage is reconciled at each --sync-interval, normally one second; today’s token totals survive router restarts through the store. Occupancy uses credits from a shared pool rather than a permanently equal division of capacity. These mechanisms have different timing and recovery rules, so test both burst traffic and long overlapping requests.

When the store is unreachable, routers restrict usage according to the documented outage rules. A router with no occupancy credits cannot admit generation work until the store answers, and a router unable to read an unseen key’s daily total returns 429 token_limit_exceeded. Oversized requests also have explicit exceptions: during a store outage, each router can admit one oversized request for an otherwise idle model, so the engines may see more than the normal shared budget. Set the router count correctly and test the outage and recovery cases in the v0.1.7 multi-router reference before treating shared enforcement as a production guarantee.

Handle rate limit breaches with bounded retry logic

HTTP 429 means too many requests, but it does not identify the exhausted resource by itself. The HTTP specification allows a Retry-After header without requiring one. Inspect the response code and the configuration behind it before deciding whether another attempt can succeed.

Router responseLikely action
429 concurrency_limit_exceededHonor Retry-After, add jitter, and retry only within the request's deadline and attempt budget.
429 rate_limit_exceeded from RPMUse bounded exponential backoff with jitter. This path currently omits Retry-After.
429 rate_limit_exceeded from serverless limitsHonor Retry-After. For embeddings and reranking, check the input-token rate. For generation, also check the output-token rate and occupancy share.
403 model_forbiddenChoose a model the key permits. If the requested model should be available to this key, update its access configuration before retrying.
429 token_limit_exceededCheck the remaining key and owner allowances. A smaller embedding batch, fewer reranking candidates, or a shorter chat request may fit. Chat callers can also lower the requested maximum output. Follow Retry-After if Router reports a temporary shared-counter refusal. For an exhausted daily budget, wait for the UTC reset or review the allowance.
400 input_too_longReduce prompt or image size. Do not retry an unchanged request.

Branch on error.code and keep the message for diagnostics. For 429 rate_limit_exceeded, check the key’s request rate. On a serverless model, check which limit the message identifies. Input-token rates apply to all three endpoints. Output rates and occupancy shares apply to generation. Use the response headers and admission metrics to narrow down which limit was reached. See Router's error reference.

Use exponential backoff within a deadline

Set a maximum attempt count and an overall deadline. Exponential backoff should increase the delay between attempts, while jitter spreads clients out so they do not return together. Coordinate application and SDK retry logic to avoid multiplying API calls. Skip automatic retries for 403 model_forbidden. Waiting for a rate limit to refill cannot grant the key access to a model. After a stream has delivered output, recovery also needs an application decision about partial results and duplicate work. Router can report stream_truncated after a stream has started with HTTP 200, so the initial status alone does not prove completion. Flag incomplete output and retry only when repeating the operation is safe. Router does not treat X-Request-ID as an idempotency key; reusing it does not prevent another inference operation.

Keep fallback routing explicit. Load balancing and fallback mechanisms select execution paths; they do not replenish a tenant allowance. A different provider can have its own rate limits, costs, model behavior, and data destination. It is not a general solution to an exhausted tenant allowance. Check request compatibility using the OpenAI-compatible API buyer guide before depending on that path.

Monitor LLM usage, rejections, and serving pressure

Track rejection causes alongside successful requests. Platform teams need to see whether rate limits reduce overload or merely shift service degradation into rejected work. Router exposes hivenet_admission_rejections_total by model and reason, with separate reasons for pool occupancy, engine pressure, RPM, input-token rate, output-token rate, and per-key occupancy.

Compare hivenet_admission_occupancy_tokens with hivenet_admission_budget_tokens, and hivenet_admission_inflight_requests with hivenet_admission_max_inflight. Exclude zero or unset denominators from utilization calculations. The admission rejection counter has no key or tenant label, so identifying one tenant requires correlation with tenant metrics or audit records. The admission metrics reference provides example queries.

With several routers sharing occupancy credits, the occupancy and in-flight gauges count each router's own reservations, while the budget and backstop gauges report full-pool limits. A local ratio is not site utilization or the router's remaining credits. For a site-wide view, sum local reservations across the routers in the same site for the same model and compare them with one current, consistent full-pool limit. Do not sum repeated limit gauges. Check that routers agree on those limits, and investigate request-count limits, credit availability, and sync-store health when b2 rejections rise. A low local occupancy ratio does not establish spare site capacity.

Also measure queue time, time to first token, completion latency, throughput, and errors. A policy that reduces successful traffic may make latency look better while rejecting more users. Assess reliability using completed work and rejected work together. The inference metrics guide explains how to compare those outcomes.

Before relying on a policy for production traffic, test:

  • Short bursts, sustained arrivals, long prompts, and overlapping long outputs.
  • Chat, embedding, and reranking requests across two keys for the same owner, first exhausting one key’s allowance, then the owner’s daily budget.
  • Requests with and without declared output maxima, plus canceled streams and timeouts.
  • Replica loss, missing engine metrics, process restarts, and any deployment with multiple router instances.
  • Daily-budget exhaustion, model-declaration errors, and external-provider fallback accounting.

Record the deployed version, policy, workload, observed responses, and measured latency. For several routers, verify the shared-store configuration above, agent connectivity to every router, and the observed limits during restarts and store outages. The production inference guide can help place these checks within the broader operating plan.

Common questions about LLM rate limiting

Is tokens per minute the same as model throughput?

No. TPM limits how many tokens an identity may consume over a time window, using the service's accounting rules. Model throughput measures tokens processed by a running workload. A quota does not certify that the backend can sustain that number of tokens at an acceptable latency.

Will a queue remove rate limits?

A queue can delay work until capacity becomes available, but it does not create capacity or increase an allowance. Bound queue length and waiting time, and reject work that cannot complete within the application's deadline.

Do rate limits guarantee fair access for users?

Rate limits can restrict a heavy user's share, but fairness depends on identity scope, workload size, and available resources. Router occupancy shares cap participation; they do not reserve service or guarantee predictable performance. With a flat quota, each key has its own daily allowance. Check the owner-wide daily cap as well when one customer has multiple keys.

What is a reasonable LLM rate limit?

There is no universal value. Start from measured serving capacity, representative request sizes, tenant allowances, and acceptable waiting time. Combine rate limits with concurrency and occupancy controls, then adjust them using observed rejection and latency data.

To evaluate these controls with your own inference servers, review Hivenet Router and its current admission documentation. Use measured results from your deployment to decide which limits protect shared capacity without rejecting work unnecessarily.

Your next workload belongs on Hivenet.

Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.