BudgetConfig
Configuration for the guard.budget() middleware.
Properties
Section titled “Properties”fallbackPricing?
Section titled “fallbackPricing?”
optionalfallbackPricing?:ModelPricing
Fallback pricing for models not in the default or custom table.
limit:
number
Maximum USD cost per session.
onLimit?
Section titled “onLimit?”
optionalonLimit?:"error"|"stop"| ((ctx,cost) =>string|void)
What to do when the budget is exceeded.
"error"(default): throwBudgetExceededError"stop": graceful stop — skip LLM call, turn ends with empty text- callback: developer decides — return string for final text, void for empty, or throw
pricing?
Section titled “pricing?”
optionalpricing?:Record<string,ModelPricing>
Per-model pricing override (USD per 1M tokens). Merged with built-in defaults.