ai.events.Usage
The tokens a model call reported. Every count is null when the provider did not report it, which is not the same as reporting zero.
Reference version
Signature
class ai.events.UsageThe tokens a model call reported. Every count is null when the provider did not report it, which is not the same as reporting zero.
Source:<builtin>/ai/ns_events/events.bamlbytes 2920–3426
Fields
input_tokens
int | nulloutput_tokens
int | nullcached_input_tokens
int | nullreasoning_tokens
int | nullcache_write_input_tokens
int | nullTokens written to the provider's prompt cache, billed above the input rate. Null when the provider reports none.
uncached_input_tokens
int | nullInput tokens billed at the full rate: input_tokens without cache
reads and writes, whichever way the provider counts them. Null when
the provider cannot tell.