Skip to main content

NeutralUsage

@forge/monorepo


@forge/monorepo / backend/src / NeutralUsage

Type Alias: NeutralUsage

NeutralUsage = object

Defined in: backend/src/models/streaming.ts:184

Properties

audioSeconds?

readonly optional audioSeconds?: number

Defined in: backend/src/models/streaming.ts:220


cachedInputTokens

readonly cachedInputTokens: number

Defined in: backend/src/models/streaming.ts:195

Input tokens served from a prompt cache — a subset of inputTokens, not an addition to it.

Read from the provider's inputTokenDetails.cacheReadTokens (task #247). It used to be read from totalUsage.cachedInputTokens, a field the AI SDK does not send — so this was zero on every turn, and computeModelCostMinorUnits billed cached tokens at the full input rate. Measured against a live model, a turn reusing a 9,700-token prefix reported 9,472 cache-read tokens and this platform recorded none of them.


cacheWriteTokens?

readonly optional cacheWriteTokens?: number

Defined in: backend/src/models/streaming.ts:206

Input tokens written into a prompt cache — also a subset of inputTokens.

Its own quantity because it is priced differently and, on some providers, priced higher than a fresh input token: Anthropic charges 1.25× to write a cache entry. Folding it into fresh input under-bills a cache write and over-credits the first turn of every conversation, which is the direction that looks like a saving and is not.

Absent means "not reported", not "none" — the rule imageCount already follows.


imageCount?

readonly optional imageCount?: number

Defined in: backend/src/models/streaming.ts:219

Non-text input, counted from what we sent rather than from what the provider reported — #185 AC-4.

Deliberately not read out of the provider's usage object. The AI SDK's neutral usage has no modality breakdown, and the providers that expose one put it in provider-specific metadata under provider-specific names — so a platform reading it would work for one vendor and silently report zero for the rest, which is worse than not reporting at all because it looks like data.

We know exactly what went out: the turn's parts. Counting there is provider-independent, always available, and auditable against the transcript — and it is the number a per-image price is charged against anyway.


inputTokens

readonly inputTokens: number

Defined in: backend/src/models/streaming.ts:185


outputTokens

readonly outputTokens: number

Defined in: backend/src/models/streaming.ts:186


reasoningTokens?

readonly optional reasoningTokens?: number

Defined in: backend/src/models/streaming.ts:207