Skip to main content
The LLM Gateway is in beta.
A rate limit policy restricts how many requests or tokens a subject can consume through the LLM Gateway in a short rolling time window. The gateway enforces the limit in real time and blocks any request that would push the subject past it, returning a 429 response with a Retry-After header and a body that names the blocking policy:
The Retry-After value is the number of seconds until the current window resets. Clients should honor this header and back off before retrying. A blocked request never reaches the provider, so it does not trigger a fallback chain, even though 429 is a default fallback trigger.
Rate limit policies and spend cap policies are complementary and can be applied together: spend caps for cost control, rate limits for throughput and traffic control.

Policy dimensions

Rate limit policies are evaluated for every incoming request.

Defaults vs. granular policies

Rate limit policies have two modes:
  1. Default policies apply automatically to every member of a subject dimension. Example: “Every user in this workspace gets a default cap of 100 requests per minute.” A user group default gives each group its own shared allowance, without a separate policy per group.
  2. Granular policies target a named subject and override the default for that subject only. Example: “The on-call engineer gets 500 requests per minute.” Editing the default updates everyone still on it.

Independent enforcement

Each subject is tracked and enforced separately. One user hitting their user-level limit does not affect other users. Members of a user group share its allowance. Accordingly, one member can exhaust the group limit for everyone in that group. If a caller belongs to multiple user groups, the request must satisfy every matching group limit and all other applicable limits.

Limits

A single rate limit policy can enforce multiple limits at once. For example, one policy can enforce both 100 requests per minute and 1,000,000 tokens per hour simultaneously. Each limit has three fields: Rules:
  • At least one limit is required per policy.
  • You cannot have two limits with the same metric and window combination within one policy.

Create a rate limit policy

Creating and managing policies requires organization:gateway:manage permission. Organization Admins and Organization Operators have it by default. For what each organization role can do, see Organization roles. Selecting a user group also requires organization:user-groups:read; see User Groups for availability and setup.
  1. Go to LLM Gateway and select the Policies tab.
  2. Click + Policy.
  3. Under Policy type, select Rate limit.
  4. Define a Scope and the subjects the policy applies to.
  5. Add one or more limits, each with a value, metric, and window.
  6. Click Create policy.
Policies take effect immediately. A rate limit policy can also carry a condition on a custom request header, so traffic from a single subject splits into separate limits by header value. Use this to give each end customer, tenant, or cost center its own throughput allowance without issuing a separate API key for each. For more information, see Header-based policies.

See also