Skip to content

UsageTracker

Defined in: core/src/usage.ts:109

Accumulates usage and cost across the calls of one run, pricing each with the rate in effect for the model that served it, so a run that switches to a backup model, or spans a time-of-day price boundary, still bills correctly. A call that carries a reported cost is billed that, with or without a rate.

new UsageTracker(): UsageTracker;

UsageTracker

get cacheSavingsUsd(): number;

Defined in: core/src/usage.ts:140

number


get costUsd(): number;

Defined in: core/src/usage.ts:136

number


get totals(): TokenUsage;

Defined in: core/src/usage.ts:132

TokenUsage

add(usage, rate?): void;

Defined in: core/src/usage.ts:116

Parameter Type
usage TokenUsage
rate? ModelRate

void


isOverBudget(maxUsd): boolean;

Defined in: core/src/usage.ts:147

A generous runaway guard, not a quality cap: the loop’s step budget is the real bound, and a run that trips this should finalize rather than fail, so set it well above any legitimate run.

Parameter Type
maxUsd number

boolean


reset(): void;

Defined in: core/src/usage.ts:151

void


subtract(usage, rate?): void;

Defined in: core/src/usage.ts:124

Parameter Type
usage TokenUsage
rate? ModelRate

void