struct

Autobot::Providers::TokenUsage

Inherits JSON::Serializable < Struct < Value < Object

Token usage from an LLM API response.

Includes optional cache token fields reported by providers that support prompt caching (e.g. Anthropic).

Constructors

new(prompt_tokens : Int32 = 0, completion_tokens : Int32 = 0, total_tokens : Int32 = 0, cache_creation_tokens : Int32 = 0, cache_read_tokens : Int32 = 0)
Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source
with_cached_input(input : Int32, output : Int32, cache_read : Int32, cache_write : Int32, total : Int32 | Nil = nil) : TokenUsage
Source

Instance methods

cache_creation_tokens
Source
cache_read_tokens
Source
completion_tokens
Source
prompt_tokens
Source
total_tokens
Source
zero?
Source