MultiTenantCostGuardOptions
Auto-generated API reference for MultiTenantCostGuardOptions.
Interface: MultiTenantCostGuardOptions
Defined in: observability/src/cost-guard-multi-tenant.ts:15
#Properties
#budgets
budgets:
Record<string,number>
Defined in: observability/src/cost-guard-multi-tenant.ts:20
Per-tenant USD budgets. Tenants not listed here either inherit
defaultBudgetUsd (if set) or are unmetered (no enforcement).
#defaultBudgetUsd?
optionaldefaultBudgetUsd?:number
Defined in: observability/src/cost-guard-multi-tenant.ts:25
Fallback budget for tenants not explicitly listed in budgets.
Omit to make unlisted tenants unmetered.
#modelOverride?
optionalmodelOverride?:string
Defined in: observability/src/cost-guard-multi-tenant.ts:62
#name?
optionalname?:string
Defined in: observability/src/cost-guard-multi-tenant.ts:63
#onCost?
optionalonCost?: (info) =>void|Promise<void>
Defined in: observability/src/cost-guard-multi-tenant.ts:52
Called whenever a tenant's running total changes. Isolated.
#Parameters
info
budgetRemainingUsd
number | undefined
budgetUsd
number | undefined
completionTokens
number
costUsd
number
promptTokens
number
tenant
string
#Returns
void | Promise<void>
#onError?
optionalonError?:CostGuardErrorHandler
Defined in: observability/src/cost-guard-multi-tenant.ts:61
Isolated sink for internal / callback failures.
#onExceeded?
optionalonExceeded?: (info) =>void|Promise<void>
Defined in: observability/src/cost-guard-multi-tenant.ts:46
Called when a tenant exceeds its budget. The runtime is NOT aborted
automatically β multi-tenant deployments typically reject the
inbound request at the gateway instead. Wire your own enforcement
here (controllers[tenant].abort(), log+drop, send 402, etc.).
Sync throws and async rejections are isolated.
#Parameters
info
budgetUsd
number
costUsd
number
tenant
string
#Returns
void | Promise<void>
#prices?
optionalprices?:Record<string,TokenPrice>
Defined in: observability/src/cost-guard-multi-tenant.ts:38
Optional price table override.
#tenantOf?
optionaltenantOf?: () =>string|undefined
Defined in: observability/src/cost-guard-multi-tenant.ts:36
Resolver called on every event. Returns the active tenant id, or
undefined to skip metering for this event entirely. The runtime
does not propagate tenant ids natively; wire this up with
AsyncLocalStorage or by calling setTenant(...) from the returned
observer immediately before invoking runtime.run.
Throws are isolated; when the resolver throws, activeTenant is used
as fallback when set.
#Returns
string | undefined