usage property

UsageDetails? get usage

Token usage of the model turn that produced this message, when known.

Covers the whole turn — tool-calling sub-requests included — and is populated only for LLM messages. Not serialized by toJson; durable usage lives in the transcript and the usage ledger.

Implementation

ai.UsageDetails? get usage => _usage;
set usage (UsageDetails? value)

Implementation

set usage(ai.UsageDetails? value) {
  if (identical(value, _usage)) return;
  _usage = value;
  notifyListeners();
}