agentskit.js

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?

optional defaultBudgetUsd?: 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?

optional modelOverride?: string

Defined in: cost-guard-multi-tenant.ts:41


#name?

optional name?: string

Defined in: cost-guard-multi-tenant.ts:42


#onCost?

optional onCost?: (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?

optional onExceeded?: (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?

optional prices?: Record<string, TokenPrice>

Defined in: cost-guard-multi-tenant.ts:24

Optional price table override.


#tenantOf?

optional tenantOf?: () => 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

Explore nearby

✎ Edit this page on GitHubΒ·Found a problem? Open an issue β†’Β·How to contribute β†’

On this page