Skip to main content
Wardin enforces budgets atomically in Redis before forwarding a request to any provider. A request over budget never reaches the provider — it’s blocked at the gateway with a structured 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

LevelSet onReset cadence
Key budgetVirtual keyMonthly
User limitUser accountMonthly
Tenant budgetOrg-wide ceilingMonthly
Key budget is the most common control. User limits let you cap a person’s total spend across all their keys. Tenant budget is the org-wide failsafe.

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:
{
  "error": {
    "type": "budget_exceeded",
    "message": "Monthly budget of $50.00 has been reached. Request a budget increase from your manager.",
    "code": 429
  }
}
For CI / headless clients the response is always structured JSON — no HTML error pages.

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 ClickHouse usage_events table records every request with its cost breakdown:
  • input_cost_usd
  • output_cost_usd
  • cache_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 percentage
  • budget.exceeded — hard limit hit
See Alerting for the webhook payload format.