> ## Documentation Index
> Fetch the complete documentation index at: https://vetta.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Budgets

> Every call is priced before it is made and refused if it would breach the cap.

Budget enforcement is structural, not a report you read the next morning. Every call is priced before it is made and refused if it would breach the cap. This is what makes it safe to leave an agent running unattended overnight.

> [!NOTE]
>
> An agent is **not creatable without a budget**. A null cap would mean no limit and no per-agent spend record at all.

> [!NOTE]
>
> **Money is integer micro-USD on the wire.** Every amount is carried and stored as an integer number of micro-USD (`1 USD = 1,000,000` micro-USD), in fields suffixed `_micro_usd` (`cap_micro_usd`, `max_task_micro_usd`, `consumed_micro_usd`). Clients display dollars for humans but convert before sending: the CLI `--budget-usd` accepts a decimal and converts client-side, and the SDK takes integer micro-USD as a `number` (e.g. `5_000_000` for \$5). Never pass a float or a string: either is refused with `validation_failed`.

## Creating an agent with a budget

A budget is set at agent-creation time — a period cap, a per-task ceiling, and the reset period.

```bash CLI theme={"system"}
naive agent create --name nightly-triage --model z-ai/glm-5.3-flash \
  --budget-usd 50 --max-task-usd 5 --budget-period month
```

```typescript TypeScript theme={"system"}
const agent = await naive.agents.create({
  name: "nightly-triage",
  model: "z-ai/glm-5.3-flash",
  harness: "pi",
  budget: { cap_micro_usd: 50_000_000, max_task_micro_usd: 5_000_000, period: "month" }, // $50 / $5
});
```

Every model call or priced tool call then passes through a pre-flight gate before it is allowed to run:

```
   model / tool call
         │
         ▼
   ┌──────────────┐
   │  pre-flight  │  compute quote (upper bound at the session's window)
   │     gate     │
   └──────┬───────┘
          │  check in order:
          │   1. org balance
          │   2. agent cap_micro_usd
          │   3. task max_task_micro_usd
          │   4. session budget
          │
   pass ──┴──▶ call proceeds
   fail ─────▶ refused → budget.exceeded emitted (agent told in-band)
```

## How pre-flight pricing works

Before each model call or priced tool call, Naive Managed Agents computes a **quote** — an upper bound on what the call will cost at the session's [completion window](https://vetta.sh/docs/concepts/completion-window.md). The quote is checked against, in order:

1. The **organization balance** — is there money? See [Credits & billing](https://vetta.sh/docs/platform/billing.md).
2. The **agent period cap** (`cap_micro_usd`) minus what it has already spent this period.
3. The **task ceiling** (`max_task_micro_usd`) minus what this session has already spent.
4. Any **session budget** you set explicitly.

If the quote would breach any of these, the call is refused and a `budget.exceeded` event is emitted. The agent is told, in-band, that it is out of budget, so it can wrap up cleanly rather than crash.

A session refused by the agent's period cap or task ceiling pauses (`budget_paused`). Raising that number on the agent, by an edit or a rollback, resumes the agent's sessions that paused on it in the last 7 days. A session that started without its own budget carries the task ceiling as its budget, so raising the ceiling also lifts that session's budget to the new ceiling; a session given its own budget keeps it, and resumes when you raise that. Lowering a cap, or changing anything else, resumes nothing; a top-up resumes the sessions the balance stopped.

## Session budgets

Beyond the agent budget, every session carries its own cap: the one you set, or the agent's `max_task_micro_usd` when you set none. Work pauses at the cap and resumes when you raise it.

```bash CLI theme={"system"}
naive session create --agent agt_01j8rf6tq2m4vz9xkp3n7c5hwd --message "Triage the inbox" --budget-usd 2.00
naive session budget --session $SID --usd 5.00   # raise (must exceed consumed)
```

```typescript TypeScript theme={"system"}
const session = await naive.sessions.create({ agent_id: agent.id, message: "Triage the inbox", budget_micro_usd: 2_000_000 }); // $2
await naive.sessions.setBudget(session.id, 5_000_000);                                 // raise to $5
```

Rules:

* A replacement cap must be strictly greater than the session's already-consumed cost.
* A session cap cannot be above the agent's `cap_micro_usd`; a larger figure is refused with `validation_failed` (400).
* A cap cannot be removed: a session always carries one. `null` is refused with `validation_failed` (400).
* A session that has ended takes no new cap (`session_terminal`, 409), and its cap is left as it was.
* Raising a cap automatically resumes work that paused at it.

## Reading spend

Everything is metered against real backend cost in integer micro-USD and attributed per component and per session. Model spend is metered across the **five-tier token ledger** — `input`, `cache_write`, `cache_read`, `output`, and `reasoning` — the same tiers the [model router](https://vetta.sh/docs/concepts/model-router.md#what-a-model-call-costs) prices each call against.

```bash CLI theme={"system"}
naive agent spend agt_01j8rk2vq6m4zx9kp7n3c5hwae --by component
naive session get $SID   # includes consumed_micro_usd
```

```json theme={"system"}
{ "by_component": { "model": 11902000, "computer": 481000, "search": 6474, "media": 390000 } }
```

Amounts are integer micro-USD: `11902000` is \$11.902. The `model` component decomposes into the five token tiers above; the other components are `computer`, `search` ([web tools](https://vetta.sh/docs/capabilities/tools.md#web-tools)) and `media` ([generation](https://vetta.sh/docs/capabilities/tools.md#generation-tools)). A component with no spend is absent, not zero.

The same figures reach the agent itself. A priced tool's result carries the settled `cost_micro_usd` — `generate_image` inline, `generate_video` and `clip_video` in the completion note and the `media.job.completed` event once the job settles — and the built-in [`session_spend`](https://vetta.sh/docs/capabilities/tools#built-in-tools) tool reads the session's own ledger: the total, the per-tier split and every media job's final cost, with `null` for a job still rendering, and `job`, what the whole job started in that session cost: every run it handed work to or started a helper in, and theirs. It is read-only and scoped to the calling session, so an agent can quote what its work cost without being handed a billing credential; the organization-wide reads stay on [`GET /v1/credits/ledger`](https://vetta.sh/docs/api/credits), `GET /v1/agents/{id}/spend` and `GET /v1/media` (`billing:read`; the media list under `agents:read`), across the API, SDK, CLI and the control-plane MCP catalogue (`credits_list_ledger`, `agents_get_spend`, `media_list_jobs`).

## Configuration reference

An agent budget has three required fields:

**cap\_micro\_usd** `integer` *required*

The total the agent may spend within its period, in integer micro-USD. The CLI `--budget-usd` and SDK helpers convert dollars to this before sending.

**max\_task\_micro\_usd** `integer` *required*

The ceiling for a single task, in integer micro-USD. A session cannot exceed this even if the period cap has room. It may not exceed `cap_micro_usd` (`validation_failed` naming the field); a cap of `0` is allowed only with a ceiling of `0`, an agent that spends nothing.

**period** `string` *required*

The reset window: `day`, `week`, or `month`.

> [card] [Next: durable runtime](https://vetta.sh/docs/concepts/runtime.md)
>
> Waiting costs storage, not compute.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.