TokenUsage class

Tracks token usage out of a completed generation or run.

Constructors

TokenUsage({required int promptTokens, required int completionTokens, required int totalTokens})
Creates a TokenUsage instance.
const
TokenUsage.fromMap(Map<String, dynamic> map)
Helper to create TokenUsage from a JSON map.
factory

Properties

completionTokens → int
Number of tokens in the generated completion.
final
hashCode → int
The hash code for this object.
no setterinherited
promptTokens → int
Number of tokens in the prompt.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
totalTokens → int
Total tokens used in the interaction.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() → Map<String, dynamic>
Converts token usage to a map.
toString() → String
A string representation of this object.
inherited

Operators

operator +(TokenUsage other) → TokenUsage
Combines two token usages if tracking accumulated totals.
operator ==(Object other) → bool
The equality operator.
inherited