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.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.

Source:<builtin>/ai/ns_events/events.bamlbytes 2920–3426

Fields

input_tokens

int | null

output_tokens

int | null

cached_input_tokens

int | null

reasoning_tokens

int | null

cache_write_input_tokens

int | null

Tokens written to the provider's prompt cache, billed above the input rate. Null when the provider reports none.

uncached_input_tokens

int | null

Input 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.