Skip to content

Graphorin API reference v0.5.0


Graphorin API reference / @graphorin/provider / / CostAccumulator

Interface: CostAccumulator

Defined in: packages/provider/src/middleware/with-cost-tracking.ts:38

A process-local cost accumulator (PS-8). Wire CostAccumulator.onUsage into withCostTracking and read the running totals — keyed by provider × model — back via CostAccumulator.totals / CostAccumulator.totalFor.

Stable

Properties

PropertyModifierTypeDescriptionDefined in
onUsagereadonly(info) => voidPass this to withCostTracking's onUsage.packages/provider/src/middleware/with-cost-tracking.ts:40

Methods

reset()

ts
reset(): void;

Defined in: packages/provider/src/middleware/with-cost-tracking.ts:46

Clear all accumulated totals.

Returns

void


totalFor()

ts
totalFor(providerName, modelId): CostTrackingTotals;

Defined in: packages/provider/src/middleware/with-cost-tracking.ts:44

Running totals for one provider × model (zeros when unseen).

Parameters

ParameterType
providerNamestring
modelIdstring

Returns

CostTrackingTotals


totals()

ts
totals(): ReadonlyMap<string, CostTrackingTotals>;

Defined in: packages/provider/src/middleware/with-cost-tracking.ts:42

Snapshot of every tracked provider::model → totals.

Returns

ReadonlyMap&lt;string, CostTrackingTotals&gt;