MultiTenantCostGuardOptions
Auto-generated API reference for MultiTenantCostGuardOptions.
Interface: MultiTenantCostGuardOptions
Defined in: cost-guard-multi-tenant.ts:4
#Properties
#budgets
budgets:
Record<string,number>
Defined in: cost-guard-multi-tenant.ts:9
Per-tenant USD budgets. Tenants not listed here either inherit
defaultBudgetUsd (if set) or are unmetered (no enforcement).
#defaultBudgetUsd?
optionaldefaultBudgetUsd?:number
Defined in: cost-guard-multi-tenant.ts:14
Fallback budget for tenants not explicitly listed in budgets.
Omit to make unlisted tenants unmetered.
#modelOverride?
optionalmodelOverride?:string
Defined in: cost-guard-multi-tenant.ts:41
#name?
optionalname?:string
Defined in: cost-guard-multi-tenant.ts:42
#onCost?
optionalonCost?: (info) =>void
Defined in: cost-guard-multi-tenant.ts:33
Called whenever a tenant's running total changes.
#Parameters
info
budgetRemainingUsd
number | undefined
budgetUsd
number | undefined
completionTokens
number
costUsd
number
promptTokens
number
tenant
string
#Returns
void
#onExceeded?
optionalonExceeded?: (info) =>void
Defined in: cost-guard-multi-tenant.ts:31
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.).
#Parameters
info
budgetUsd
number
costUsd
number
tenant
string
#Returns
void
#prices?
optionalprices?:Record<string,TokenPrice>
Defined in: cost-guard-multi-tenant.ts:24
Optional price table override.
#tenantOf?
optionaltenantOf?: () =>string|undefined
Defined in: cost-guard-multi-tenant.ts:22
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.
#Returns
string | undefined