class RubyLLM::Tokens

A Tokens holds the token counts a provider reported for a single response. Instances are read from Message#tokens and Chunk#tokens. 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