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

> ## Agent Instructions
> These docs cover three products: TrustGate (AI agent gateway), TrustGuard (runtime security), and TrustTest (AI red teaming). Start from each product overview for the definition and How it works. Prefer the .md URL next to a page in /llms.txt when you need the full article. Use /llms-full.txt for a single-file dump of the site.

# LLM Budget

> Cap what an application may spend on models over a window, in tokens or dollars, and choose whether the cap rejects or downgrades.

Applies to **LLM**.

A rate limit caps how often; a budget caps how much. A handful of long-context
requests to an expensive model cost more than thousands of short ones, so a rate
limit alone leaves spend unbounded. The budget is the ceiling on tokens or dollars
an application, or an end user behind it, may consume in a window — the thing
that keeps a runaway agent from becoming an invoice.

Caps usage over a window, in **tokens** or in **dollars**, and decides what
happens when the cap is reached.

| Setting              | Meaning                                                                                                                                                                                                      |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Unit** and **Max** | Tokens (whole numbers) or dollars (fractional), per window.                                                                                                                                                  |
| **Time window**      | Seconds to days. Anything under a minute is raised to a minute.                                                                                                                                              |
| **When exceeded**    | **Reject** the request, or **downgrade** the model to a cheaper one on the same provider.                                                                                                                    |
| **Per-model limits** | Tighter caps for specific models or families — `claude-opus-*`. A request is checked against the main budget and against the most specific rule matching its model; exceeding either triggers the behaviour. |
| **Counting**         | Total, input only, or output only.                                                                                                                                                                           |
| **Group by header**  | A separate budget per value of a header — `X-User-Id` — inside the policy scope.                                                                                                                             |

As with the rate limiter, the budget is one counter gateway-wide and one per
application when targeted.

The budget is checked before the request goes upstream, using an estimate, and
the actual usage is charged after the response.

### Dollars are only as true as the rates

A dollar budget prices tokens the same way **Analytics** does: your
[contract pricing](/trustgate/registry/models#contract-pricing) where you set it,
otherwise list price. Enter the contract before the budget, or a discounted
contract stops too early.

### Downgrade, not reject

Downgrading keeps the application working at its ceiling — `gpt-4o-mini` instead
of `gpt-4o` — instead of returning errors. The target must be on the same
provider. Reject is for spend that must not happen at all.

## Where to apply it

| Scope               | Typical use                                                     |
| ------------------- | --------------------------------------------------------------- |
| **Gateway-wide**    | An organisation-level ceiling nobody can opt out of.            |
| **Targeted**        | Per-tenant or per-application quotas.                           |
| **Group by header** | Per end user inside one application, without a policy per user. |

When the goal is cost, pair a budget with [smart routing](/trustgate/llm/routing#smart-routing):
routing lowers the bill on every request, the budget puts a hard stop under it.
