DocsAPI Reference

Budgets and limits

Cap what an organization, a team or a member spends, per period and per model, and see what is left.


A budget limits usage. It does not purchase credit, move money into a team wallet or guarantee that a request can be funded. Applicable usage limits and prepaid credit admission are checked separately.

Budget capacity and wallet credit are separate checks
Usage budgetDoes the policy allow more usage in this window?A blocking limit can return 429.
Available creditCan the payer fund this request?A credit refusal can return 402.
Buying credit does not increase a budget. Raising a budget does not add credit.
A request must satisfy every applicable blocking budget and, when billing is enforced, credit admission. Other access and model checks still apply.

Build a budget

With organization limit-management permission, open Organization › Budgets & limits in the sidebar and choose Set budget.

  1. Give it a name, such as "Opus research". The name appears in alerts, in the member's view and in the 429 a refused request receives.
  2. Choose who it is for: the organization, a named team, a named member or one of your agents. For an organization or a team, choose One shared budget (one pool) or A separate budget per member (each member of the team gets the same allowance).
  3. Enter the Usage budget (USD) and choose a period:
    • Calendar month, week (Monday start), quarter or year: resets at 00:00 on the boundary.
    • Rolling days (1–90): the trailing N days, today included. Spend is kept per day, and the oldest day's spend is released at midnight.
    • Date range: from the first day to the end of the last day, once. Outside the range the budget neither counts nor blocks.
    • Fixed duration: from the first request, for the chosen length.
  4. Calendar periods and rolling days follow the budget's time zone. New budgets use the organization's default zone, shown under the page title (change it there). Changing the default never moves an existing budget.
  5. Optionally limit the budget to models. Type to search the catalog, then pick an exact model, a model line such as anthropic/claude-opus-*, or a vendor such as openai/*. A pattern also covers models added to the catalog later. A model that is not in the catalog is struck through and refused on save.
  6. Choose Track only — requests continue or Stop requests at the limit, and the alerts (50%, 80% and 100% by default).
  7. Choose Review budget, check the summary, then save.

If the organization changes while you are saving, return to the intended workspace and review again. A stale save is refused rather than applied to the new organization.

How limits combine

Every budget that applies to a request is checked, and the tightest one decides. A more specific budget does not override a stricter parent.

A request to a model outside a budget's model set is not counted by that budget. It is checked against the other budgets that apply. So an Opus-only team budget stops Opus requests at its limit, while the same key keeps working for other models, within the organization's budget.

A team budget binds the requests of keys attributed to that team. Choose the team when you create the key. Membership alone does not attribute a request.

In-flight requests reserve capacity. Completion settles actual usage against the original reservation. A request finishing after a boundary still belongs to its original period, and retrying settlement does not charge the budget twice.

Budgets for an agent's own users

An agent's key often lives on a server that serves people of its own: a public page, a chatbot, an internal tool. An agent budget can split the agent's spend between those people using the request tags the server sends:

  • Only requests tagged limits the budget to requests carrying every tag you list, for example tier:guest.
  • A separate budget per tag value with a tag key such as user gives every user: value its own allowance: user:u_1, user:g_7, and so on.

For example, for an agent behind a public page:

BudgetSettings
Agent capAll of the agent's requests, one shared $150 a day
Guest poolTagged tier:guest, one shared $5 a day
Each guestTagged tier:guest, separate per user, $0.25 a day
Each clientTagged tier:client, separate per user, $20 a day

The server then sends, on every request:

X-Tokamak-Tag: app:drive,tier:guest,user:g_4f2a
  • Tags only divide what the agent may already spend. Every budget still applies, so a wrong tag cannot raise the agent's total.
  • A request that a per-value budget applies to must carry exactly one well-formed tag for its key. Otherwise it is refused with 400 budget_tag_required, never charged to a shared pool.
  • Use an identifier for each person that stays stable across their visits (for a guest, a signed cookie rather than a per-request token). A new identifier starts a new allowance, which is why a shared pool should cap the total.
  • These budgets read tags only on the agent's own keys. On any other key, tags remain labels for analytics.
  • Allowances per tag value do not send alerts; put alerts on the agent's shared budgets.

See Request tags for the refusal reasons and tips for agent servers.

Alerts

When settled usage crosses one of a budget's thresholds, Tokamak emails the organization's owners, administrators and billing administrators. It also emails the members the budget binds: the team's members, or the member whose own allowance it is. Each threshold is announced once per period (once per day for rolling budgets). Track-only budgets alert too.

Open a budget to see its Alerts log: every threshold crossed and each delivery, marked sent, failed or skipped. A self-hosted deployment without email configured still records the alert and marks its deliveries skipped. See upgrading for the TOKAMAK_NOTIFICATION_SMTP_* settings.

Read a budget

Choose a budget's name to open it. The page shows:

  • used, reserved and remaining for the current period, and for a rolling budget the spend released at the next midnight;
  • for a budget with a separate budget per member, every member of the organization in one table: used, limit, remaining, when their window opened and when it resets, and whether they are near or at the limit. Search by name or show only members near or at the limit. A member with no window yet still has their full allowance;
  • spend by member and by model, exactly as the budget counted it;
  • its settings, its alert log and its adjustment log.

To help someone who ran out:

  • Extend adds an amount in USD (+$25, +$50, +$100 or your own) to the window that is open now. It applies to that window only: when it resets, the next window starts from the budget's normal limit. A rolling budget cannot be extended, because its limit covers a range of days; reset it instead.
  • Reset ends the current period and releases its reservations; for a rolling budget, every day in its range. The next request opens a fresh, full allowance.

Both accept an optional note and are recorded in the budget's Adjustments log with who made them and when. Neither is a refund or a credit purchase, and neither changes the budget for anyone else.

Your budgets

Budgets & limits shows members every budget that can apply to their requests: their own, their teams' and the organization's. Each card shows what is left, when it frees up and what they spent in it. Members never see other members' spend.

Responses to requests that a stopping budget covers carry two headers, so agents and scripts can show the same figures:

HeaderMeaning
X-Tokamak-Budget-RemainingUSD the tightest stopping budget has left after this request's own reservation
X-Tokamak-Budget-ResetWhen that budget next resets or releases usage (RFC 3339)

Both are set before the first byte, so streamed responses carry them too.

When requests stop

A blocking usage-limit breach returns 429. The body's budget object names the budget, its period and when it resets. Retry-After and X-RateLimit-* give the same information as headers. Adding credit does not remove a budget cap. A credit refusal is usually 402 and belongs in Billing & credits. A service failure is not evidence of either an empty wallet or an exhausted budget.

See Usage and spending for cost interpretation.

On this page