AiUsage class

Token usage and latency for a single provider call.

All counts are best-effort: a provider that omits a usage field (or returns an unexpected shape) reports 0 for it. cachedInputTokens is the subset of inputTokens served from the provider's prompt cache (Anthropic cache_read_input_tokens, OpenAI prompt_tokens_details.cached_tokens, Gemini cachedContentTokenCount). requestMs is the wall-clock time of the HTTP request, used to compute generation speed. Instances sum with + so the agent loop can aggregate per-turn usage across a whole interaction.

Constructors

AiUsage({int inputTokens = 0, int outputTokens = 0, int cachedInputTokens = 0, int requestMs = 0})
const

Properties

cachedInputTokens int
final
hashCode int
The hash code for this object.
no setterinherited
inputTokens int
final
outputTokens int
final
requestMs int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
totalTokens int
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator +(AiUsage other) AiUsage
operator ==(Object other) bool
The equality operator.
inherited

Constants

zero → const AiUsage
The additive identity (all counts zero), used as an accumulator seed.