Budgets
Per-call maximums and spend limits for the account, a key or a session
A budget limits what can be spent before a call runs. Budgets are checked when the hold is taken, together with the runs already in flight, so parallel calls cannot overrun them.
Every active budget that applies to a call counts: an account budget, the budget of the key or OAuth grant making the call, and the budget of the call’s session_id.
Create one
Managing budgets needs the manage scope (the dashboard has it; API keys get it only when created with it).
Change or disable it with PATCH /v1/budgets/{budget_id}, or in Settings → API.
When a budget stops a call
The run is recorded as BLOCKED with BUDGET_EXCEEDED (or MAX_COST_EXCEEDED when the per-call maximum is lower than what the input can cost) and nothing is charged. An agent should report the reason and the remaining budget to the user rather than splitting the work into smaller calls to get around it.
Budgets and agents
- Give each agent task a
session_idand a session budget so one runaway task cannot spend the whole wallet. - Give each CI job or server its own API key with a key budget.
- MCP hosts connected with OAuth are callers too; their runs show the host’s name and count against key budgets for that grant.