Skip to content

TokenUsage

Defined in: core/src/types.ts:164

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.


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: number;

Defined in: core/src/types.ts:165


outputTokens: number;

Defined in: core/src/types.ts:175


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.


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.