---
title: "Budgets"
description: "Budgets limit spend in each window, in a meter's units or in dollars across several meters."
---

# Budgets

A budget is a limit on spend in each window. A reservation must fit every budget that counts it,
or it is denied and nothing is charged.

## Units or dollars

A budget counts one of two ways:

- **In units**: one [meter](/tidegate/guide/meters)'s spend, in that meter's own units, such as tokens or
  calls. A price never moves its limit. A rate limit is a budget in units on a meter that counts
  calls.
- **In dollars**: one or more meters' spend, each reservation at its meters'
  [prices](/tidegate/guide/prices) when it was made. One budget in dollars can cap everything a vendor
  charges, input and output tokens of every model together, so a call that switches among its
  models stays under the same cap. Its meters are fixed when it is defined, though: a meter
  added later, for a new model, isn't counted until the budget is defined again with it (see
  Changing a budget, below).

Units of different meters don't add up, so a budget over several meters is always in dollars.
Its limit is in micro-dollars in the API, and in dollars on the pages.

A budget in dollars counts only spend its meters have a price for: defining one over a meter with
no price now is refused, and spend from before a meter's first price isn't counted. A reservation it counts adds what each line cost,
rounded up to the micro-dollar, so the budget never counts less than was spent. A settlement
moves it by what the settled quantities cost instead, at the same prices. When a price changes
for a time in the budget's current window, the budget counts that spend at the new price, which can
take it past its limit, as a settlement above the estimate can.

## Windows

A budget's windows repeat back to back from an **anchor**. A window is either a fixed duration,
such as a day, or a number of calendar months, counted in UTC. Without an anchor, a budget's
first window starts at its first reservation.

Month windows clamp to the end of the month: anchored on January 31, windows start February 28
(or 29), then March 31. Windows also repeat backward from the anchor, so it can lie in the future.

## Narrowing to an app

A budget is for one [app](/tidegate/guide/apps), or for the whole organization. An app's budget counts only
the reservations that app's keys make; an organization's budget counts every reservation.

## Narrowing to an environment

A budget is for one [environment](/tidegate/guide/environments), such as `staging`, or for every environment.
An environment's budget counts only the reservations that keys in that environment make. A
budget can be for an app and an environment at once.

## Narrowing with labels

Reservations carry labels, such as `member=user_42` or `job=summary`. A budget can count only
the reservations that carry given labels: a budget with `job=summary` caps summaries and nothing
else.

## Splitting by a label

A budget can be **split** by label keys, keeping spend apart for each of their values. Split by
`member`, one budget caps every member separately, each at the full limit. A reservation that
doesn't carry a split label isn't counted by that budget at all, so make sure your services send
it.

## Budgets within budgets

The Budgets page groups budgets by vendor, then by the meters they count, and draws each group's
budgets as a tree: a budget sits under the narrowest one that counts everything it counts, in
windows of the same length, and in the same unit. Budgets over several of a vendor's meters come
first in the vendor's section; budgets over several vendors' meters come first on the page. For example, a meter's total, then
one app's part of it, then that app's bulk jobs, then each user's bulk jobs. A narrower budget is
defined like any other, with the same meters, unit, and window length; the page draws it under
the broader one.

When narrower budgets, each for one app, each for one environment, or each on one value of a
label, together allow more
than the budget above them, the page says so: they compete for its limit, or, when there is only
one, it never refuses anything, since the broader budget fills first.

## Watching spend

The Budgets page shows each budget's spend in its current window against its limit: in dollars
for a budget in dollars, and for one in units, in dollars too where the meter has a price. The
counts at the top of the page say how many budgets are over their limit, near it (at 80% or
more), and under it; each one filters the list to those budgets.

## Setting the limit

The form takes a limit in the budget's unit: the meter's units, or dollars. Check the meters it
counts: one, counted either way, or several, from any vendors, counted in dollars. Each vendor's
box checks all of its meters at once. It can also share a limit evenly among
a number of a split's values. The budget keeps only each value's share: Tidegate learns your users
only as they spend, so it can't divide a limit among them itself.

## Changing a budget

Only the limit can change; it applies from the next reservation. A budget's meters, unit, app,
environment, labels, split, and window are fixed: to change one, archive the budget and define a
new one, with another id. To add a new model's meters to a budget in dollars, define a new budget
with them, anchored where the old one is, so it counts the spend already in this window, then
archive the old one. A budget defined with an anchor counts the spend already in its current
window; one without starts counting at its next reservation. Either way, it counts every
reservation made while it was being defined, by the time the definition answers. A reservation
made at the very moment a price changes is repriced about ten seconds after. The limit, a freeze, or
an archive applies to the reservations that start after the change; one already under way, for a
millisecond or so, is judged by what was in effect when it started.

## Freezing and archiving

Freeze a budget to stop the spend it counts at once: every reservation it counts is refused,
whatever its spend, until you unfreeze it. Its denials say so, with `"frozen": true`.

Archive a budget to retire it: it stops counting and limiting spend, and the Budgets page lists it
apart, under its archived budgets. Its record stays, and its id stays its own. Restore it to put
it back in effect; it counts from its next reservation, so what was reserved while it was
archived stays uncounted. That holds for a budget archived just after it was defined, too: if it
hadn't yet finished counting the spend already in its window, restoring it doesn't finish it. Budgets are archived rather than removed, so the history of what limited
spend, and when, is never lost.
