Skip to main content

Interface: SpendBudgetOptions

Defined in: packages/agentos/src/api/runtime/spendBudget.ts:29

A budget's settings.

Properties​

budgetId?​

optional budgetId: string

Defined in: packages/agentos/src/api/runtime/spendBudget.ts:46

The id the guard keeps the spending under; a budget given none makes one.


guard?​

optional guard: CostGuard

Defined in: packages/agentos/src/api/runtime/spendBudget.ts:44

The guard that holds the spending; a budget given none makes its own, with no daily or single-call cap. On a guard given, the budget sets the session cap of its id to maxCostUSD and keeps the daily cap the guard holds for that id.


maxCostUSD​

maxCostUSD: number

Defined in: packages/agentos/src/api/runtime/spendBudget.ts:31

The most the run may spend, in US dollars.


maxTotalTokens?​

optional maxTotalTokens: number

Defined in: packages/agentos/src/api/runtime/spendBudget.ts:33

The most prompt and completion tokens the run may use, counted by this budget: zero or more.


onLimitReached?​

optional onLimitReached: "throw" | "warn" | (info) => void

Defined in: packages/agentos/src/api/runtime/spendBudget.ts:39

What a call that would pass the budget does: 'throw' (the default) refuses it with CostCapExceededError; 'warn' logs once per call and lets it run; a function is told what was about to be refused and the call is then refused as with 'throw'.


parent?​

optional parent: SpendBudget

Defined in: packages/agentos/src/api/runtime/spendBudget.ts:59

A budget this one draws on. Every check asks the parent first, with the same estimate, and every record and outside cost is added to the parent after this budget. A refusal by the parent, or by any budget above it, runs this budget's own onLimitReached function (when it is one) with the refusing budget's SpendLimitInfo, after the refusing budget's own, before the error goes on.


unpriced?​

optional unpriced: "refuse" | "allow"

Defined in: packages/agentos/src/api/runtime/spendBudget.ts:52

A call on a model with no price row: 'refuse' (the default) refuses it with UnpricedModelError, since its cost could not be counted; 'allow' lets it run and counts its cost as nothing, while the token budget and a budget already past its cap still refuse it.