TextUsage
class TextUsage extends Usage
Methods
Create text generation usage data.
Get the instance as an array.
Reconstruct an instance from a previously serialized toArray() payload.
Get the input tokens that were neither read from nor written to a prompt cache.
Sum two optional counts, preserving null when neither was reported.
Details
at line 18
__construct(int $inputTokens = 0, int $outputTokens = 0, int|null $cacheReadInputTokens = null, int|null $cacheWriteInputTokens = null, int|null $reasoningTokens = null)
Create text generation usage data.
in
Usage at line 24
int
totalTokens()
Get the total number of input and output tokens.
at line 77
array
toArray()
Get the instance as an array.
in
Usage at line 43
array
jsonSerialize()
Get the JSON serializable representation of the instance.
at line 33
static TextUsage
fromArray(array $data)
Reconstruct an instance from a previously serialized toArray() payload.
at line 47
int
uncachedInputTokens()
Get the input tokens that were neither read from nor written to a prompt cache.
at line 55
TextUsage
add(TextUsage $usage)
Add the given usage to the current usage and return a new usage instance.
at line 69
static protected int|null
sum(int|null $a, int|null $b)
Sum two optional counts, preserving null when neither was reported.