Skip to content
DocsStar33Playground

Spend budgets and alerts

How-to guideLast updated 2026-12-02 · 53a7a7361Quickstart

A budget caps the money your runs spend. You set it on Costs (/runs/costs, see Where the spend goes) or in Settings > Budgets; both show the same list. Everything stays on your machine.

Each budget has a scope, a period, a limit and a warning percent:

Choice Options
Scope All runs, one agent, or one model (written provider/model, for example anthropic/claude-sonnet-4-6)
Period Per run, per day (UTC) or per month (UTC)
Limit An amount in USD, above 0 and at most 1,000,000
Warn at A whole percent from 1 to 99 of the limit; 80 by default

There is one budget per scope, scope target and period (edit the existing one instead of adding a second), and at most 50 budgets. A budget can be switched off without deleting it; a disabled budget covers nothing. Days and months are UTC calendar windows, the same days the Costs page groups by. Spend is each run’s stored total (the billed total the Costs page uses), counted in the window the run started in.

A day or month budget lists its spend, state (ok, warn, exceeded), reset time and pace: when the pace so far would cross the limit before the window ends, the budget says so.

Cortex Settings at the Budgets section: a daily budget for all runs marked Near limit, monthly budgets for one model and one agent marked On track, and a per-run cap, each with an On switch. Cropped to show: The budget list: the daily budget near its limit with its pace, two monthly budgets and the per-run cap.
Budgets: a USD limit per run, day or month for all runs, one agent or one model. Each shows its spend, state, reset time and pace. The budget list: the daily budget near its limit with its pace, two monthly budgets and the per-run cap.

The budgets and spend in the screenshots on this page come from a seeded demo, not from real usage.

When a day or month budget reaches its warning percent or its limit, Cortex tells you in four places: a toast, a banner on the Costs page, a badge in the top bar, and the alert history under the budget list. Each budget raises one warn and one exceeded alert per window, so a busy day does not repeat them. History also records blocked starts, overrides and runs stopped by a per-run cap, and keeps the newest 500 rows.

Cortex Costs page: a banner saying the daily budget for all runs is near its limit, the budget list, and the spend, tokens and model-call totals of the recent runs, with a Budget near limit badge in the top bar.
Costs: where tokens and spend go, with the same budgets and a banner when one is near its limit. The top bar carries a badge too.

The three periods enforce differently.

  • Per run. The cap is handed to the framework as its own budget (.withBudget({ costLimit, warningRatio })), so the framework checks the cap before each model call and ends the run once it is crossed; a run can end up to one call over the cap (see Where the limits are soft). A run that ends this way is marked stopped with terminationReason: budget_exceeded, and its header shows a chip, Stopped by budget: $X cap. This applies to chat, desk runs and gateway agents alike, because they all build through the same Cortex function. If an agent’s own configuration already sets a tighter cost limit, that limit stays; with several per-run budgets that cover a run, the smallest wins.
  • Per day and per month. A budget that is used up blocks new runs and chat turns that spend money. The refusal is an HTTP 402 with a plain message that names the budget, the spend, and when it resets (UTC). Nothing already running is stopped by a day or month budget.
  • Override once. The blocked-start dialog offers Override once. The override covers one start, can be used a single time, and is held in memory for 10 minutes (a Cortex restart revokes it). The override is recorded in the alert history.

Local providers (ollama, litellm, test) are shown as free (local). They never count toward a budget, never get a per-run cap and are never blocked. A model with no known price adds no dollars, so a total that includes one is a lower bound (shown as “at least”), never a guess. Because of this, a budget scoped to a local model never fires.

Do not rely on a per-run cap as a hard ceiling. Day and month budgets are the firm control, because they block new runs.

  • A per-run cap can end one call over. Checked before each model call; a run can end up to one call over the cap. Measured: a $0.08 cap stopped a tool-calling run after 2 calls and $0.09; before the per-call check it allowed 10 calls and $0.45. Calls made after the run stops (non-kernel, no-tool calls) can add cost beyond the cap plus one call. Use a day or month budget to block new runs once the limit is used up, and set the per-run cap below the amount you can afford to lose.
  • Running gateway agents are not start-blocked between fires. A day or month budget blocks a fire only when its run starts; an agent that is already running keeps going. Only its per-run cap applies.
  • Ad-hoc desk runs only count under the all-runs and model scopes. A desk run that is not a saved or gateway agent has no agent id, so an agent-scoped budget does not see it.
  • No channel notifications yet. Alerts reach the Cortex UI only; Telegram and other channels are not told.
  • Retention and spend. Cortex keeps the 50 most recent runs per agent. Before a run is dropped, its priced cost is copied to a small archive kept for 62 days, so a month budget still counts it. Deleting a run by hand does not archive its spend, so the month total drops by that amount.

The routes are for building tooling on top of Cortex; the UI uses the same ones.

Route Purpose
GET /api/budgets Every budget with its label and status, plus the newest alerts
POST /api/budgets Create a budget (400 for a bad body, 409 for a duplicate or past 50)
PATCH /api/budgets/:id, DELETE /api/budgets/:id Change or remove a budget
GET /api/budgets/events?runId= Alert history, newest first, at most 100 rows; runId narrows to one run

A start that a budget blocks (desk run, rerun, eval run, fork, and chat turns) answers 402 with { error, blocked: { message, overrideToken, budgets } }. To go ahead once, repeat the same request with the header x-cortex-budget-override: <overrideToken>. The Cortex UI does this for you after you confirm.

Install

Bun (recommended)bun add reactive-agents
Node 22.5+npm install reactive-agents

Get notified on new releases

Release notes, about once a month.