TokenUsage
Defined in: core/src/types.ts:164
Properties
Section titled “Properties”cachedInputTokens
Section titled “cachedInputTokens”cachedInputTokens: number;Defined in: core/src/types.ts:169
Cache-hit subset of inputTokens. Providers auto-cache repeated
prefixes and bill the hit portion far cheaper, so it must be tracked
separately to cost a turn correctly. 0 when the provider reports none.
cacheWriteTokens?
Section titled “cacheWriteTokens?”optional cacheWriteTokens?: number;Defined in: core/src/types.ts:174
Tokens written to cache, also a subset of inputTokens, so the total
stays the whole prompt the window has to hold. Anthropic bills these
above the input rate; the OpenAI-shape auto-cachers bill them at it.
0 when not reported.
inputTokens
Section titled “inputTokens”inputTokens: number;Defined in: core/src/types.ts:165
outputTokens
Section titled “outputTokens”outputTokens: number;Defined in: core/src/types.ts:175
reasoningTokens?
Section titled “reasoningTokens?”optional reasoningTokens?: number;Defined in: core/src/types.ts:182
The part of outputTokens spent thinking, when the provider reports it.
Already inside outputTokens, so never add it again. It is the number
that explains a turn that came back empty with a length finish: the
reasoning ate the budget. Anthropic does not report it; absent there.
reportedCostUsd?
Section titled “reportedCostUsd?”optional reportedCostUsd?: number;Defined in: core/src/types.ts:191
What the provider says this call cost, in USD: its bill, not our
arithmetic. Only OpenRouter sends one today. It is the one number a rate
cannot give, because OpenRouter serves one model id from many hosts at
different prices, and only the response knows which host answered.
Absent when the provider sent none, or sent one we could not trust.
costUsd and UsageTracker bill it over any rate.