Anthropic::TokenCountResponse
Inherits JSON::Serializable < Struct < Value < Object
Response from the token counting API
count = client.messages.count_tokens(
model: Anthropic::Model::CLAUDE_SONNET_4_6,
messages: [{role: "user", content: "Hello, Claude!"}]
)
puts "This message would use #{count.input_tokens} input tokens"
Constructors
new(pull : JSON::PullParser)
Sourcenew(input_tokens : Int32, cache_creation_input_tokens : Int32 | Nil = nil, cache_read_input_tokens : Int32 | Nil = nil)
Sourcenew(*, __pull_for_json_serializable pull : JSON::PullParser)
SourceInstance methods
cache_creation_input_tokens
Number of tokens that would be written to cache (if using prompt caching)
cache_read_input_tokens
Number of tokens that would be read from cache (if using prompt caching)