Budgets

Budget overview

Zelyx enforces spend caps at seven independent layers. Every layer uses atomic reservation — parallel agents cannot race past the same cap.

The seven layers

LayerScopeResetsWhere to configure
Company dailyAll calls in your workspaceMidnight UTCBudgets page
Team dailyCalls tagged with a specific teamMidnight UTCBudgets page → Teams
Project dailyCalls tagged with a specific projectMidnight UTCBudgets page → Projects
Per-key dailyCalls from one Zelyx keyMidnight UTCAPI Keys → key creation
Per-model dailyCalls to one specific modelMidnight UTCBudgets page → Models
Run budgetOne job or pipeline runNever (exhausted or manual reset)X-Zelyx-Run-Budget-USD header
Session limitOne interactive sessionNever (in-memory, resets on restart)X-Zelyx-Session-Limit-USD header
NoteLayers you do not configure are unlimited. A budget of 0 means unlimited, not zero dollars.

Enforcement order

On each call, the gate checks all applicable budget layers. If any layer is exhausted, the call is blocked. The first exhausted layer wins — the call does not proceed even if all other layers have remaining budget.

  1. Session limit (if X-Zelyx-Session-Id + X-Zelyx-Session-Limit-USD provided)
  2. Per-model daily budget (if the model has a cap)
  3. Per-key daily budget (if the Zelyx key has a daily budget set)
  4. Company daily budget
  5. Team daily budget (if the call is tagged with a team)
  6. Project daily budget (if the call is tagged with a project)
  7. Run budget (if X-Zelyx-Run-Id provided)

Atomic reservation

Before forwarding a call to the provider, Zelyx reserves the estimated cost against every applicable budget layer. This happens in a single atomic database write — no other request can consume the same budget slot simultaneously.

After the call completes, the actual cost (from the provider's usage response) replaces the estimate. If the actual cost is lower, the difference is returned to the budget. If higher, the overage is added.

TipBecause reservation is atomic and estimate-based, a budget of $10.00 may allow a call estimated at $0.02 even when $9.99 has been spent, but then block the next call. The reservation prevents two concurrent requests both seeing $9.99 remaining and both proceeding.

Setting a company daily budget

  1. Go to Budgets.
  2. Enter a daily cap in the Company budget section and click Save.
  3. Select an overage policy — what happens when the cap is hit (see Overage policies).
  4. Optionally set an alert threshold (e.g. 80%) to get notified before the cap is hit.

Setting a team or project budget

On the Budgets page, scroll to Team budgets or Project budgets. Enter a team or project name (must match exactly the value you send in X-Zelyx-Team or X-Zelyx-Project) and a daily cap.

Important: tagging must match

A team budget for backend only applies to calls where the request (or the key default) carries X-Zelyx-Team: backend. If calls are untagged, they are not counted against the team budget — only the company budget applies.