Skip to main content
Two catalog policies control volume and spend: Both respect policy scope (Gateway-wide or Targeted consumers) and support Enforce / Observe (and throttle where the plugin allows).

Configure in the console

  1. Open PoliciesCatalog.
  2. Choose Rate Limiter or LLM Budget.
  3. Set Scope (mode + gateway-wide / targeted consumers).
  4. Fill the form (details below).
  5. Save. Verify with Playground or Analytics → Policy / Cost.

Rate Limiter

rate_limiter counts requests in a sliding window at pre_request.

Settings

Limited responses carry 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

  1. PoliciesCatalogLLM Budget.
  2. Under Budget, set unit, max, and time window.
  3. Under When limit is exceeded, choose behaviour (and downgrade target if needed).
  4. Optionally add Per model limits.
  5. Optionally open Advanced Settings (group-by header, counting).
  6. Set mode and scope, then save.
The console uses a dedicated form (not the generic schema renderer).

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

  1. At pre_request, estimate whether the request would exceed the remaining budget for the scope (and matching per-model rule, if any).
  2. If over limit under Enforce:
    • Reject → stop upstream with a budget error.
    • Downgrade → rewrite the request model to Downgrade to and continue.
  3. At post_response, accrue actual tokens (or estimated dollars) against the counter.
  4. Under Observe, over-limit traffic is not blocked; decisions still appear on policy events for Activity / Analytics.

Example

Token pool example:

Choosing a scope