Number of tokens in the prompt (input)
Number of tokens in the completion (output)
Total tokens used (prompt + completion)
Optional cacheTokens served from the provider's prompt-prefix cache (Anthropic
cache_read_input_tokens). Optional — undefined when no aggregated
message reported cache activity, so consumers can distinguish
"provider did not report" from "zero hits".
Optional cacheTokens written to the provider's prompt-prefix cache as a new entry
(Anthropic cache_creation_input_tokens). Same undefined-vs-zero
convention as cacheReadTokens.
Token usage statistics for LLM API calls.
Interface
ITokenUsage
Example