Skip to content

Gateway Usage Limits

Usage limits bound how much a Gateway workload can consume. A limit is scoped to an organization, project, or API key, and can optionally be narrowed to a specific request model id. The runtime checks all matching limits before routing and rejects the request when any limit would be exceeded.

Guardrails — the rules that inspect request and response content — are documented separately in the Guardrails section. Both controls produce structured project evidence, but they answer different questions: limits decide whether more consumption is allowed, guardrails decide whether the content itself is acceptable.

Limit scopes#

Scope Applies to Typical use
API key One project API key Per-application or per-environment boundary
Project All requests in the project Project-wide budget or throughput
Organization All projects in the organization Organization-wide hard ceiling
Model per API key One model on one API key Restrict an application to a specific model budget
Model per project One model across the project Cap an expensive model inside a project
Model per organization One model across the organization Organization-wide model spend guard

The narrowest matching scope wins first. For example, a model_per_api_key limit on one model id is checked independently from a project-level token budget.

Metrics and modes#

Metric Modes Typical use
Requests Rate limit Bound request throughput
Tokens Rate limit or budget Bound short-window throughput or total token volume
Cost Budget Bound estimated and actual USD spend recorded from provider usage

Supported windows are minute, hour, day, week, month, quarter, year, custom, and lifetime.

Configure a limit#

In the Workbench:

  1. Open API keys.
  2. Expand the project key used by the workload.
  3. Under Limits, select Add limit.
  4. Choose metric, type, limit, period, and scope.
  5. For a model-specific scope, enter the exact request model id.
  6. Save the limit and monitor used, reserved, remaining, and reset values.

The runtime reserves estimated usage before routing, then settles successful requests against actual usage when the provider reports it. Failed requests release their reservation.

Rejection contract#

When admission would exceed a policy, the Gateway returns 429:

json
{
  "error": {
    "code": "gateway_budget_exceeded",
    "message": "Gateway budget exceeded",
    "reason": "cost_budget_exceeded",
    "policyId": "policy_123",
    "resetAt": "2026-08-02T00:00:00.000Z"
  }
}

Rate-limit rejections use rate_limit_exceeded. Responses include:

text
Retry-After
RateLimit-Limit
RateLimit-Remaining
RateLimit-Reset

Do not implement automatic retries for a cost or lifetime budget rejection. Retry only when the policy has a reset time and the workload can wait.

Success checks#

  • The saved rule appears under Limits with the expected scope, metric, and window.
  • A request at the limit returns 429 with the matching code, and the trace records the policy id that rejected it.
  • Removing or widening the rule allows the request again without restarting the Gateway.