Token usage tracking across turns.
Accumulates input/output token counts from provider responses so callers can track costs and enforce limits.
Summary
Functions
Estimates cost in cents given per-million token prices.
Replaces (does not accumulate) the existing estimated_cost_cents.
Merges usage from a provider response into accumulated usage.
Returns total tokens consumed (input + output).
Types
@type t() :: %Alloy.Usage{ cache_creation_input_tokens: non_neg_integer(), cache_read_input_tokens: non_neg_integer(), estimated_cost_cents: number(), input_tokens: non_neg_integer(), output_tokens: non_neg_integer() }
Functions
Estimates cost in cents given per-million token prices.
Replaces (does not accumulate) the existing estimated_cost_cents.
Merges usage from a provider response into accumulated usage.
@spec total(t()) :: non_neg_integer()
Returns total tokens consumed (input + output).