TokenUsage
Defined in: core/src/types.ts:188
Extended by
Section titled “Extended by”Properties
Section titled “Properties”cachedInputTokens
Section titled “cachedInputTokens”cachedInputTokens: number;Defined in: core/src/types.ts:193
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:198
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.
contextTokens?
Section titled “contextTokens?”optional contextTokens?: number;Defined in: core/src/types.ts:232
The prompt of the turn’s LAST model pass, cache included, where the
vendor states it (Anthropic’s usage.iterations). A hosted tool loop runs
several passes inside one turn and bills their sum, so inputTokens can
read far larger than the window ever held. Compaction reads this first.
hostedCalls?
Section titled “hostedCalls?”optional hostedCalls?: Partial<Record< | "web_search" | "web_fetch" | "code_execution" | "file_search"| "image_generation", number>>;Defined in: core/src/types.ts:225
The hosted tool calls this turn ran, by type: as the vendor states them
(Anthropic, OpenRouter), or as the stream showed them. Absent when none
ran. Vendors bill these per call, beside the tokens; ModelRate.hosted
prices them.
inputTokens
Section titled “inputTokens”inputTokens: number;Defined in: core/src/types.ts:189
outputTokens
Section titled “outputTokens”outputTokens: number;Defined in: core/src/types.ts:202
reasoningTokens?
Section titled “reasoningTokens?”optional reasoningTokens?: number;Defined in: core/src/types.ts:209
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:218
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.
toolUsePromptTokens?
Section titled “toolUsePromptTokens?”optional toolUsePromptTokens?: number;Defined in: core/src/types.ts:201
Input tokens added by the provider’s tools, when reported (Gemini).
Already included in inputTokens.