429.
How budget enforcement works
The Lua script is atomic — no race condition between checking and decrementing, even across multiple gateway replicas. This is the only place budget is enforced; there is no secondary check elsewhere.Budget granularity
| Level | Set on | Reset cadence |
|---|---|---|
| Key budget | Virtual key | Monthly |
| User limit | User account | Monthly |
| Tenant budget | Org-wide ceiling | Monthly |
Budget increase requests
Developers can request a budget increase directly from the Developer section of the dashboard. Managers approve or deny requests; approved increases apply immediately and optionally expire at a set date — when they expire, the limit reverts to the baseline.Over-budget response
When a request is blocked by a budget:Spend tracking
Actual spend is committed to Redis after a successful response — using the real token counts from the provider, not the estimate used for admission. The dashboard reflects real spend, not estimates. The ClickHouseusage_events table records every request with its cost breakdown:
input_cost_usdoutput_cost_usdcache_creation_cost_usd(for Anthropic prompt caching)cache_read_cost_usd
Budget alerts
Configure a webhook alert at a spend threshold (e.g., 80% of budget) in Console → Webhooks. Events:budget.threshold_reached— configurable percentagebudget.exceeded— hard limit hit