Skip to content
providerkit
GitHub

UsageTracker

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

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:176

number


get costUsd(): number;

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

number


get totals(): TokenUsage;

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

TokenUsage

add(usage, rate?): void;

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

Parameter Type
usage TokenUsage
rate? ModelRate

void


isOverBudget(maxUsd): boolean;

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

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:187

void


subtract(usage, rate?): void;

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

Parameter Type
usage TokenUsage
rate? ModelRate

void