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

# Budgets and forecasts

> Set a spend limit for a scope and a period, choose what happens at the limit, and read the forecast against it.

**Spend › Budgets** is the one list of budgets. A budget limits what a scope spends over a week, month, quarter or year. Only finance and admin roles can create, edit or delete budgets. Members don't see the tab.

> [!NOTE]
>
> Budgets count AI calls at the metered price. That is the cap: a budget never counts below it. **Spend** views and **Customers** can show a provider's settled bill when it is lower (from two days after a day ends, and with no environment filter). So a budget can read higher than the same spend on Explore. The cap stays safe because a discount that hasn't been billed yet can't let spend slip past the limit. See [How TensorCost counts AI spend](https://docs.tensorcost.com/concepts.md).

## Create a budget

**1. Pick a scope**

Workspace (all spend), environment, team, project, provider, model, instance family, a cloud tag (`key=value`), or agent. To give every developer or every customer a limit of their own, set **Who it applies to** instead; see [Budgets for each developer or customer](#budgets-for-each-developer-or-customer).

**2. Pick a period**

Week, month, quarter or year, with a start date and an optional end date.

**3. Set the limit and what happens at it**

See the table below. The default is notify only.

**4. Choose who is told**

Thresholds default to 75, 90 and 100 percent. Notifications are in-app by default; add a connected destination for email, Slack or PagerDuty. See [Alerts](https://docs.tensorcost.com/control/alerts.md).

An agent budget counts only that agent's metered calls, matched by the agent id the call carries. Cloud bills don't name an agent, so none count there. Team and tag budgets count your cloud bills plus AI calls that carry the matching label and aren't already on one of those bills.

You can nest budgets. A child budget names a parent, and children can't total more than the parent. When a call matches a budget, every ancestor applies too and the tightest cap wins.

## How a budget becomes an alert

A threshold alert fires once per period when spend first crosses it. TensorCost checks when new spend is ingested and, for proxied calls that raise no event, on a sweep every five minutes.

```mermaid theme={null}
flowchart LR
  S["New spend,<br/>or the 5-minute sweep"] --> V["Budget re-read"]
  V --> T{"New threshold crossed?<br/>75, 90, 100 by default"}
  T -->|"no"| N["Nothing sent"]
  T -->|"yes"| Sv["Severity:<br/>100 critical, 90 warning, below that info"]
  Sv --> R{"Linked burn rate rule?"}
  R -->|"yes"| CH["Its channels:<br/>email, Slack, PagerDuty"]
  R -->|"no"| IA["In-app only"]
```

## What happens at the limit

| Setting | What it does |
| - | - |
| Notify only | Alerts people. Never touches a call. |
| Warns callers | At 90 percent of the limit, calls through the TensorCost proxy get a warning. |
| Blocks at the limit | The proxy refuses a request that would push spend past the cap. |

Be precise about where this bites:

* **Only calls that pass a TensorCost check are refused**, and new GPU launches. That means calls through the proxy, and calls from an SDK at `govern` or above, which asks TensorCost first. Calls that your SDK at `observe` reports after the fact are counted, but they can't be blocked by a budget.
* Calls already running finish.
* **If the budget check can't be reached, calls go through.** Spend is judged from a cache at most 30 seconds old, so a cap can be crossed slightly before it bites.
* Where a metered price sits above a discounted bill, the call still counts toward the budget, so a hard cap stops slightly early rather than late.

Agent period budgets (a day or month limit for one agent, a team or everyone) are configured in **Authority › Limits**, not here. See [Limits](https://docs.tensorcost.com/control/limits.md).

## Budgets for each developer or customer

**Who it applies to** on the New budget form has four choices: **The whole workspace**, **Each developer** and, on Scale and Enterprise, **Every customer keeps a margin** and **Each customer, a fixed amount**. The last three create one budget that holds every developer, or every customer, to a limit of their own. They have no scope, no parent budget and no forecast, and once created they keep their period and tool. You can change the limit, enforcement and alerts. The budget's detail page lists the 50 members furthest into their limit.

### Each developer

One limit applies to every developer, per tool or across all tools. A Claude Code limit is enforced at the TensorCost gateway. A Cursor or GitHub Copilot limit is pushed to the vendor, which does the refusing. Bedrock and All tools can only notify. The setup, and what each tool does at the limit, are on [Coding agents](https://docs.tensorcost.com/developers/coding-agents.md#budgets-per-developer).

### Every customer keeps a margin

This is the per-customer budget. Instead of one dollar limit, you set a margin floor, a share of revenue each customer must leave you. It reads the revenue on [Cost per customer](https://docs.tensorcost.com/spend/customers.md#revenue-and-margins), so it only works for customers whose revenue you have pushed or uploaded. If you don't share revenue, use [a fixed amount](#each-customer-a-fixed-amount) instead.

* **Every customer keeps (% margin)** is 0 to 95.
* The period is a calendar month and the budget starts on the 1st. Revenue is recorded by month, so the floor can't run on any other period.

**The limit.** A customer's limit for the month is their USD revenue × (1 − floor%). At a 40 percent floor, a customer paying $1,000 can cost $600. The revenue used is the larger of this month's and last month's. Usage-based and cost-plus businesses invoice in arrears, so this month's revenue often doesn't exist until the month closes, and a small prorated first invoice shouldn't cut the limit mid-month. The budget says which month set each customer's limit.

A customer with no USD revenue in either month has no limit and can't cross the floor. A month with zero revenue, or refunds above revenue, gives no limit of its own. The budget's detail page gives the reason for each customer without one (no revenue recorded, revenue not in USD, refunds above revenue), and the budget sends one notice a month naming them. Only USD is compared; nothing is converted.

**What it holds.** The floor judges a customer's counted AI spend for the month. A call is held to it only if the call names its customer, through the `customer` tag (see [Attribution](https://docs.tensorcost.com/developers/attribution.md)), and only on a path TensorCost checks: the proxy, or the SDK at `govern`. Spend takes a little while to be counted, so the proxy also keeps a running count of the calls it has sent and judges the larger of the two. A model TensorCost has no price for is counted at a high estimate, the price of a top-tier model, so a customer on a cheap, unpriced model can be refused earlier than their real spend warrants. That estimate lapses a day after the model stops being called unpriced.

The Enforcement setting works as on other budgets:

| Setting | What happens |
| - | - |
| Notify only | Alerts people. Calls are never touched, and the proxy doesn't read the floor. |
| Warns callers | At 100 percent of the customer's limit, the customer's calls go through with an `X-TensorCost-Budget-Warning` header. |
| Blocks at the limit | At 100 percent, the customer's next call is refused. |

**At 90 percent: a cheaper model first.** When a customer is within 10 percent of the limit, TensorCost can move their calls to a cheaper model before it refuses anything. This happens only when all of these hold:

* The call goes through the proxy. An SDK at `govern` asks TensorCost before the call and doesn't step down.
* The call isn't a stream, and has no tools or function calls in it, including earlier tool turns in the conversation.
* You have a [route](https://docs.tensorcost.com/control/routing.md) for that model that has gone live, and it isn't paused. Live routing is on, and the published layer is `steer` or `route`.
* The route's target is on the same provider, so the customer's own provider credential is used, and approved-models rules allow it.

Every eligible call moves to the route's target, whatever the route's rollout share. If there is no verified route, nothing steps down and the call carries on to the refusal at 100 percent. The proxy waits at most 300 ms for the answer, and if it can't get one, it sends the call as it was. A step-down never turns into a refusal.

A stepped-down call carries `x-tc-decision: layer=route; action=route; reason=margin_floor_near`, is recorded as a routed call, and its spend row names the model that ran. The call is resent once on the customer's own model only when the attempt is provably never billed. Anything else may have run, and a second send could bill it twice, so it isn't resent and the error is returned. TensorCost counts an attempt as never billed in these cases:

* The connection or TLS handshake failed before anything was sent.
* The provider answered 401, 403, 404 or 429, which every provider refuses before any model work.
* The provider is Anthropic, or a GPU endpoint of your own, and answered with another error status. Those two don't charge for failed requests. A 504 is the exception, since a timeout in front of the provider doesn't show whether the call ran.
* The provider is Bedrock and answered 400, a request refused before the model was called.

Everything else is not resent: a timeout after the send, any 504, a 408 or 424 from Bedrock, a 408 or a content-filtered 400 from Azure OpenAI (it bills those), and any other error status from OpenAI, Azure OpenAI, Bedrock or Vertex, such as a 500, 502, 503 or 529.

**At 100 percent: a refusal, or a warning.** With **Blocks at the limit**, the customer's next call is refused with HTTP 403:

```json theme={null}
{
  "error": {
    "code": "MARGIN_FLOOR_REACHED",
    "message": "Customer \"acme\" has reached its 40% margin floor: its AI spend this month is $600 against a limit of $600, based on this month's revenue.",
    "customer": "acme",
    "floor_pct": 40,
    "cap_cents": 60000,
    "spent_cents": 60000
  }
}
```

The SDKs treat this code as a TensorCost refusal and don't fall back to the provider. Calls already running finish. With **Warns callers**, nothing is refused.

**When it can't be checked.** The floor fails open. If TensorCost can't read a customer's figures, the revenue or cost behind them, or the counter, the call goes through, and its spend row is marked `admit_unavailable`. The SDK at `govern` records the same reason when it can't reach the check.

### Each customer, a fixed amount

If you'd rather not share revenue, give every customer the same monthly allowance: "each customer, \$500 a month". It is on Scale and Enterprise, as the margin floor is, and it needs no revenue at all.

* **Each customer, per month (USD)** is the amount in dollars. Every customer gets the same one.
* A limit that caps (**Warns callers** or **Blocks at the limit**) must be monthly and start on the 1st, UTC. It is held against each customer's calendar-month spend. A **Notify only** limit isn't enforced at the call, so it can use another period.
* One template carries either a fixed amount or a margin floor, never both. Make a second template if you want both.

The limit judges a customer's counted AI spend for the month, on the same counter and under the same rules as the floor. A call is held to it only if it names its customer through the `customer` tag. A customer with nothing counted yet starts from zero, so a new customer's first burst is held too. Like the floor, it fails open: if TensorCost can't read the figures, the call goes through.

With **Blocks at the limit**, a customer at its amount has its next call refused with HTTP 403 and its own code, so you can tell "this customer used its allowance" from "this customer stopped being profitable":

```json theme={null}
{
  "error": {
    "code": "CUSTOMER_LIMIT_REACHED",
    "message": "Customer \"acme\" has reached its $500 monthly limit: its AI spend this month is $500.",
    "customer": "acme",
    "cap_cents": 50000,
    "spent_cents": 50000
  }
}
```

It never steps a customer down to a cheaper model. A fixed amount only refuses or warns. A margin floor still steps down at 90 percent, as above, and that is the reason to choose one.

## The forecast

One forecast serves the budget page, the budget status API, pace alerts and [Ask](https://docs.tensorcost.com/ask.md), so they agree.

* It works in whole UTC days and never counts part of today.
* AI calls and owned GPUs run forward at their daily average.
* Cloud bills land late, so they run at the rate billed through the last billed day.
* Scoped budgets (team, provider, tag) use their own burn-down without the cloud lag correction.
* For the first three whole days of a period, or while cloud bills are due but none has landed, the forecast is drawn but holds back its verdict. Don't act on it yet.

## Budget detail

Open a budget for its limit, actual, burn rate and projected figures, what it counts, its parents and children, what happens at the limit, and a burn-down with the last twelve periods. It also lists the rules that act on that budget's scope, with a shortcut to add one.

**Pace watch** ("tell me when we are ahead of pace") works for week and month budgets only. It can be switched off for the whole workspace, in which case the budget says it won't notify anyone yet.


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