class RubyLLM::Tokens

A Tokens holds normalized token counts for a provider attempt, a response, or an aggregate. Read them from Chat#tokens, Message#tokens, Chunk#tokens, and individual operation results such as Embedding. Counts the provider did not report are nil.

response = chat.ask "What is the capital of France?"
response.tokens.input       # standard input tokens
response.tokens.output      # billable output tokens
response.tokens.cache_read  # prompt cache reads
response.tokens.cache_write # prompt cache writes