A budget is a spend limit. Use one to stop a runaway job, a test environment, or one person's keys from using more than you intended. A budget refuses new requests once the limit is reached.

Budgets are set by admins of an organization, and the owner of a personal space.

## What you can limit

| Target | Counts |
|---|---|
| **Workspace** | Everything spent through every key in that workspace, whoever owns the key. |
| **Member** | Everything spent through keys that person owns, across all workspaces in the organization. Only in organizations. |

Both can apply to the same request. When they do, whichever limit is reached first stops it.

Each target has up to three limits, one per period:

| Period | Resets |
|---|---|
| **Daily** | At 00:00 UTC |
| **Weekly** | On Monday at 00:00 UTC |
| **Monthly** | On the 1st at 00:00 UTC |

Fill in the ones you want. An empty limit means no limit for that period. A limit of zero is not allowed.

## Set a budget

Open **Budgets** in the sidebar. The table lists every workspace and member that has a budget, with how much has been spent against each period.

- **Add budget** opens a dialog. Choose a workspace or member, then enter the amounts in dollars.
- On the **Workspaces** and **Members** pages, a row's menu has **Set budget**.
- To change a budget, edit it from its row. To remove it, choose **Remove budget** in the row menu.

A target that already has a budget is edited from its row, not added again, so there is one place to change it.

### Setting a limit counts what you already spent

When you add a limit to something that had none, it counts everything already spent in the current period. If you set a $100 daily limit on a workspace that has already spent $120 today, it is over its limit at once and the next request is refused. The console warns you when this happens.

Changing a limit that is already in force does not recalculate anything. It only moves the ceiling.

## What happens at the limit

New requests are refused with a `402` and `period_quota_exceeded`. The error says which period was reached, the limit, how much has been used, when it resets, and whether it was a workspace or a member budget. See [Errors & rate limits](/docs/errors).

Budgets are checked when a request **starts**. A response that is already streaming is never cut off, so a request that begins just under a limit can finish and push usage a little over it. The table reflects this: used can be higher than the limit, and the row is marked as at its limit.

When the period resets, requests work again. To resume sooner, raise the limit.

## Notifications

Reaching a limit does **not** send an email. In the console, a limit turns amber once 80% of it is used and red when it is reached. The Budgets page and the **Workspaces** and **Members** lists are where you see who is at their limit, so check them if requests start failing with `402`.

## New workspaces

A new workspace has no budget. If your policy is that every workspace has a cap, add one when you create it. The Budgets page lists workspaces that do not have one.

## Budgets, key limits, and credits

Three separate things can stop a request over money:

| | Limits | Resets |
|---|---|---|
| **Budget** | Spend per period, on a workspace or member | Daily, weekly, or monthly |
| **Key spending limit** | Total lifetime spend of one key | Never |
| **Wallet** | The credit available | When you add credits |

See [API keys](/docs/api-keys) and [Credits](/docs/credits).
