Skip to content

Request rate limits

Last updated: 2026-11-26T03:21:52-03:00 (UTC-3)

Rate policies cap admitted inference requests. They do not count tokens, estimate cost or grant access to a model. Budgets and TPM cover those separate limits; access control still applies before model admission.

The gateway uses shared PostgreSQL counters and the database clock. Replicas share a policy’s ceiling. A rejected admission consumes no slot in its own transaction; it does not refund an earlier, separate admission phase. Concurrency policies remain process-local and are labeled separately in the console.

No policy means no request ceiling from this subsystem. The following new flags default tofalse; staging a policy does not activate its flag or grant identity/model permission.

Flag Enables Prerequisite
rate_limits Existing shared request counter admission Configured PostgreSQL
model_rate_limits Global requests to one canonical public model alias rate_limits
key_model_rate_limits Requests to that alias from one key rate_limits
long_window_rate_limits New model-policy windows of1hour or1day rate_limits, plus the applicable model scope flag
rate_policy_management Existing API/console policy management UI, identity and team management; an authorized administrator

The first two model-scope flags are independent: enabling key×model limits does not require a global model policy. Flags are operator controls; tenant entitlements never turn off an operator’s active ceiling. Vendor classification can additionally restrict configuration writes without stopping established inference on license expiry.

Profile Required scope fields Limit Window
tenant (T168, organizations) Organization ID rpm only, one counter for every key of the organization’s teams; no max_concurrent Fixed UTC minute
Legacy key, team, end_user Existing subject_id rpm0..1000000; zero requires an applicable nonzero concurrency cap Fixed UTC minute, unchanged
model subject_id: canonical exact alias requests_per_window1..1000000 1m default, 1h or 1d
key_model subject_id: key ID; model_id: canonical exact alias requests_per_window1..1000000 1m default, 1h or 1d

A new model policy has effective RPM and concurrency equal tozero; positive legacy limits cannot be combined with it. Rawzero remains an unset value for existing Go serialization. model_id is reserved for the compound profile. The creation preset shown in the console is not a default ceiling: no policy is created automatically. Disabled policies do not admit or charge requests.

Model references must identify a current canonical exact alias. An alias_of request resolves to that canonical model, so a transparent alias does not provide another counter. Wildcard patterns/dynamic wildcard aliases are outside this profile. A key policy applies an additional restriction; it does not authorize the key to use the model.

The two admission groups have explicit ordering:

  1. Existing key/team/end-user RPM runs during caller admission, before parsing the requested model. Existing behavior for invalid bodies and process-local concurrency is preserved. A transcript upload (POST /v1/traces, agent runs) takes one slot in these same key, team, organization and end-user counters, after its key and scope are checked and before its body is read; concurrency caps and the model policies of group 2 do not apply to it.
  2. New matching model/key×model policies run after authorized canonical resolution, before model work. All matching policies and windows in this group admit atomically; one refusal rolls back every increment in that group.

A later model refusal can therefore consume a prior legacy RPM slot. This is not an all-or-nothing transaction across the two groups. Use a model policy when the ceiling is specifically about admitted requests to that alias.

Cache hits count. Retries and provider-target fallback within the admitted alias do not add another model admission. Semantic fallback to another alias and actual internal inference have their own canonical admission. Auto-routing admits its public router alias before classification and the selected destination before that destination does work; the same canonical alias is counted once per request. A selected-destination refusal can occur after classifier work, so its cost is not promised to be zero. The existing moderation guardrail exception applies to both rate groups, avoiding a rate refusal that would bypass the guardrail.

Chat, translated/native JSON and multipart inference, native Gemini and token-count operations use their authorized canonical ingress. Realtime checks the new group per generated response; it does not add a model slot merely for upgrading the WebSocket or issuing a client secret. Existing handshake/per-response legacy RPM remains unchanged. Resource-only file/container/conversation/fine-tuning lifecycle operations and video polling/deletion keep their existing legacy checks; the gateway does not infer a requested model from an account resource.

This fragment assumes that chat-default is an existing canonical alias in the same complete configuration. Replace it with your actual alias. The global policies below apply simultaneously; either refusal rolls back the new group’s increments.

features:
rate_limits: true
model_rate_limits: true
key_model_rate_limits: false
long_window_rate_limits: true
rate_policies:
- id: chat-minute
subject: model
subject_id: chat-default
requests_per_window: 60
window: 1m
disabled: false
- id: chat-hour
subject: model
subject_id: chat-default
requests_per_window: 600
window: 1h
disabled: false
Key What it does
rate_policies[].id Unique identifier of the policy, used by the console, the API and the 429 answer
rate_policies[].subject What the ceiling counts: key, team, end_user, tenant, model or key_model (table above)
rate_policies[].subject_id The ID of that subject: key, team, organization or canonical alias
rate_policies[].model_id For key_model only: the canonical alias the key is limited on
rate_policies[].rpm Requests per fixed UTC minute for the legacy and tenant profiles
rate_policies[].requests_per_window Requests per window for the model and key_model profiles, 1–1,000,000
rate_policies[].window 1m (default), 1h or 1d; the longer windows need long_window_rate_limits
rate_policies[].disabled true keeps the policy without admitting or charging requests through it
rate_policies[].mode enforce (default) refuses past the limit; observe counts and reports without refusing (below); needs rate_limit_observe_mode

For a compound policy, select an existing declared or active managed key ID, set subject: key_model, keep the key ID in subject_id, and put the canonical alias in model_id. Enable key_model_rate_limits. Never use a cleartext API key as subject_id.

YAML is the base. The authorized versioned API and Rate policies console can create/update a validated PostgreSQL override; removing an override explicitly restores its declared YAML base when one exists. This does not revoke a key, change model access or migrate counter history to another identity. A changed policy scope/window/limit has a distinct counter identity; editing it can start a new bucket. Review limit changes as operational changes, rather than treating them as a harmless rename.

Try a limit before enforcing it. With the operator flag rate_limit_observe_mode (off by default; requires rate_limits), a policy with mode: observe takes its slot in the same shared counter as an enforced one, but never refuses: a request past the limit is admitted, and counted as one the policy would have limited. Watch it for a few days, then set mode: enforce (or remove the line): the counter and its history stay the same, because the mode is not part of the counter’s identity.

features:
rate_limits: true
model_rate_limits: true
rate_limit_observe_mode: true
rate_policies:
- id: chat-hour-trial
subject: model
subject_id: chat-default
requests_per_window: 600
window: 1h
mode: observe

Where the would-limit requests are reported:

Where What
GET /api/v1/admin/rate-policies/status?status_version=2 and Rate policies mode: "observe", would_limit (this window) and would_limit_15m (the windows that started in the last 15 minutes; the current window alone for a 1h or 1d policy); used can exceed the limit
/metrics and OTLP gateway_rate_limit_would_limit_total{policy}
Logs A rate_limit_would_limit line per policy at most once a minute on each replica, with policy_id, subject, window, would_limit (the requests past the limit since the previous line) and the IDs of the request that wrote it
The request span rate_limit_would_limit: the observed policies the request went past
Alert channels The rate_limit_would_limit event, at most once per policy every 15 minutes, with the subject, the limit and the window (never an end user); a replica offers it once per policy and bucket, so a policy far below real traffic costs no write per request
  • What it applies to: request counts (rpm, requests_per_window) of every profile. A concurrency cap (max_concurrent) is always enforced; a policy that has one cannot observe (422).
  • Mixed groups: an enforced policy in the same admission group still refuses; a refused request counts for no policy of its group, observed ones included. The key, team and end-user group is admitted before the model group (what consumes a slot): a request past an observed key or team policy and then refused by an enforced model policy has taken its slot and is reported as would-limit by the first group.
  • Without the flag a configuration with mode: observe is refused, so turning the flag off cannot silently start enforcing an observed policy: set the policies to enforce or remove them first.
  • Old replicas do not read mode and would enforce the policy: roll every replica to this release before writing mode: observe.

Use the current version from GET /api/v1/admin/config when calling PUT /api/v1/admin/rate-policies/{id}. The request contains version and the typed policy (with mode for an observe-only policy); session authentication, CSRF, role permissions, current subject/model authority and feature-aware licensing are checked server-side. A stale version returns409. Reload and review the change before saving again; the console does not silently adopt a newer version for an old draft.

The following complete example requires curl, jq, a current console cookie jar/CSRF token and an existing canonical alias. It creates a model-hour override; it does not enable flags automatically.

Terminal window
BASE_URL="${BASE_URL:-http://localhost:8080}"
: "${COOKIE_JAR:?Set the path to your authenticated console cookie jar}"
: "${CSRF_TOKEN:?Set the CSRF token from that console session}"
: "${MODEL_ID:?Set an existing canonical exact alias}"
POLICY_ID='model-hour'
VERSION=$(curl --fail-with-body -sS --cookie "$COOKIE_JAR" \
"$BASE_URL/api/v1/admin/config" | jq -er '.version')
jq -n --arg id "$POLICY_ID" --arg model "$MODEL_ID" \
--argjson version "$VERSION" \
'{version:$version,policy:{id:$id,subject:"model",subject_id:$model,
requests_per_window:600,window:"1h",disabled:false}}' |
curl --fail-with-body -sS --cookie "$COOKIE_JAR" \
-X PUT "$BASE_URL/api/v1/admin/rate-policies/$POLICY_ID" \
-H "X-CSRF-Token: $CSRF_TOKEN" -H 'Content-Type: application/json' \
--data-binary @-
curl --fail-with-body -sS --cookie "$COOKIE_JAR" \
"$BASE_URL/api/v1/admin/rate-policies/status?status_version=2"

GET /api/v1/admin/rate-policies/status?status_version=2 is the supported mixed-window status contract. Dynamic per-end-user counters remain excluded instead of being shown as misleading aggregate headroom. It identifies the configuration version and each row’s scope, unit, limit, start and reset. observed_at is the database observation time; it is null when shared rate limits are off, without affecting optional process-local concurrency reporting. The console validates that identity against its current configuration before showing usage/remaining. Missing, stale, denied or failed observations are unavailable, not zero. The defaultV1 response remains the legacy minute/concurrency view for compatible older clients and identity details; it is not a complete model-window report.

Parameter metadataV14 defines the new form’s typed bounds/defaults and distinguishes a creation preset from an operational default. A missing/malformed descriptor or write-capability projection makes the new controls unavailable; it never grants permission. Existing legacy controls retain their established contract. The Swagger contract describes request/response fields and the same-origin endpoint explorer provides runnable examples.

A full matching bucket returns 429 rate_limit_exceeded with Retry-After derived from its fixed UTC reset; the gateway does not sleep or invoke a provider to satisfy admission. The answer names the policy that refused, so the caller knows which ceiling it hit and when to come back:

{"error": {"code": "rate_limit_exceeded", "message": "Inference request limit exceeded: policy chat-minute allows 60 requests per minute; it resets at 2026-11-26T15:04:00Z"}}

The message gives the policy id, its limit, its window (per minute, per hour or per UTC day) and the reset in UTC. It is the same on every route a policy counts: chat, Responses, Messages, embeddings, Gemini, token counts, the other inference routes, passthrough, agent transcript uploads (which count in the key’s requests-per-minute policies only), and each Realtime response (the error event’s message, with retry_after). Only the refusing policy is named, and it is always one that matched the caller’s own key, team, end user, organization or model; the message never carries a counter, another subject’s ID or the end-user value. An end-user policy adds (per end user): the limit is each end user’s, and the message does not say which end user. When several policies are full at once, one of them is named: the key, team, end-user and organization policies are checked first, then the model policies. Budget and token refusals name their policy the same way (budgets and TPM). Database/repository failure returns503 when an applicable ceiling cannot be proven. No counter decision depends on an observer, browser clock, Collector or Grafana.

Daily buckets reset at00:00UTC, hourly buckets at the UTC hour and minute buckets at the UTC minute. These are aligned windows, not rolling durations from the first request. Pruning preserves every active supported bucket. A restart or another replica does not provide extra slots; the database is authoritative.

Upgrade and stop every old replica/worker before enabling new profile flags. Older binaries do not enforce these fields or flags, and their minute-counter cleanup can delete an active daily bucket older than one hour; mixed old/new enforcement is not supported. Preserve the normal PostgreSQL/configuration backup and roll back configuration together with an older binary. This feature reuses the existing counter table; it does not require a new schema migration. No managed-cloud, optional-adapter or paid-provider certification is implied by local PostgreSQL validation.

A model-policy denial records the already-authorized canonical model and the request/trace IDs, without inventing a provider attempt, reported tokens or spend. Use the returned X-Request-Id and traceparent to correlate the decision with the request explorer/OTLP journey. A counter observation and a provider execution receipt are different evidence.

m7gtw[email protected]