CostGuardOptions
Auto-generated API reference for CostGuardOptions.
Interface: CostGuardOptions
Defined in: observability/src/cost-guard.ts:48
#Properties
#budgetUsd
budgetUsd:
number
Defined in: observability/src/cost-guard.ts:50
Hard budget in USD. Aborts the run when exceeded.
#controller
controller:
AbortController
Defined in: observability/src/cost-guard.ts:55
AbortController to signal the runtime to stop. The runtime picks this up via RunOptions.signal (RT13).
#modelOverride?
optionalmodelOverride?:string
Defined in: observability/src/cost-guard.ts:78
Force a specific model id if the runtime doesn't emit one.
#name?
optionalname?:string
Defined in: observability/src/cost-guard.ts:80
Observer name for tracing.
#onCost?
optionalonCost?: (info) =>void|Promise<void>
Defined in: observability/src/cost-guard.ts:64
Called whenever the running total changes. Useful for progress UI. Sync throws and async rejections are isolated.
#Parameters
info
budgetRemainingUsd
number
completionTokens
number
costUsd
number
promptTokens
number
#Returns
void | Promise<void>
#onError?
optionalonError?:CostGuardErrorHandler
Defined in: observability/src/cost-guard.ts:76
Isolated sink for internal / callback failures. Never allowed to escape.
#onExceeded?
optionalonExceeded?: (info) =>void|Promise<void>
Defined in: observability/src/cost-guard.ts:74
Called when the budget is exceeded (just before / after abort bookkeeping). Sync throws and async rejections are isolated.
#Parameters
info
budgetUsd
number
costUsd
number
#Returns
void | Promise<void>
#prices?
optionalprices?:Record<string,TokenPrice>
Defined in: observability/src/cost-guard.ts:59
Optional price table override. Partial β merged over DEFAULT_PRICES.