Both respect policy scope (Gateway-wide or Targeted consumers) and support Enforce / Observe (and throttle where the plugin allows).
Configure in the console
- Open Policies → Catalog.
- Choose Rate Limiter or LLM Budget.
- Set Scope (mode + gateway-wide / targeted consumers).
- Fill the form (details below).
- Save. Verify with Playground or Analytics → Policy / Cost.
Rate Limiter
rate_limiter counts requests in a sliding window at pre_request.
Settings
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
and Retry-After.
LLM Budget
token_rate_limiter, labeled LLM Budget in the catalog, caps LLM usage by
provider tokens or USD over a time window. It checks the budget at pre_request and
accrues usage at post_response.
This is the catalog quota policy for spend over time. Use tokens for raw usage or
dollars for cost. Dollar mode uses the same rates as telemetry and Analytics:
registry contract pricing first
(override, else discount × catalog), then the models.dev catalog. A policy
custom_pricing map (API-only) still wins over the registry when set.
Configure in the console
- Policies → Catalog → LLM Budget.
- Under Budget, set unit, max, and time window.
- Under When limit is exceeded, choose behaviour (and downgrade target if needed).
- Optionally add Per model limits.
- Optionally open Advanced Settings (group-by header, counting).
- Set mode and scope, then save.
Settings (UI ↔ backend)
Budget
The form shows a live summary, e.g. “Allow 1000 tokens per hour.”
When limit is exceeded
Per model limits (optional)
Tighter budgets for specific models. Match by slug or wildcard (e.g.claude-opus-*).
Most specific pattern wins.
Advanced
Fields present in the plugin but not edited in the console (left at defaults / API-only)
include stream usage injection, count cache reads, and custom pricing.
Runtime
- At pre_request, estimate whether the request would exceed the remaining budget for the scope (and matching per-model rule, if any).
- If over limit under Enforce:
- Reject → stop upstream with a budget error.
- Downgrade → rewrite the request model to Downgrade to and continue.
- At post_response, accrue actual tokens (or estimated dollars) against the counter.
- Under Observe, over-limit traffic is not blocked; decisions still appear on policy events for Activity / Analytics.
Example
Choosing a scope
Related
- Policies overview
- Request size — payload size limits
- Analytics — Cost and Policy tabs
- Registries — contract rates for dollar budgets
- Smart routing — route by Simple / Medium / Hard labels; pair with LLM Budget for spend ceilings