class ImageUsage extends TextUsage

Methods

__construct(int $inputTokens = 0, int $outputTokens = 0, int|null $cacheReadInputTokens = null, int|null $cacheWriteInputTokens = null, int|null $reasoningTokens = null, int|null $imageInputTokens = null, int|null $imageOutputTokens = null)

Create image generation usage data.

int
totalTokens()

Get the total number of input and output tokens.

from  Usage
array
toArray()

Get the instance as an array.

array
jsonSerialize()

Get the JSON serializable representation of the instance.

from  Usage
static TextUsage
fromArray(array $data)

Reconstruct an instance from a previously serialized toArray() payload.

int
uncachedInputTokens()

Get the input tokens that were neither read from nor written to a prompt cache.

add(TextUsage $usage)

Add the given usage to the current usage and return a new usage instance.

static int|null
sum(int|null $a, int|null $b)

Sum two optional counts, preserving null when neither was reported.

Details

at line 15
__construct(int $inputTokens = 0, int $outputTokens = 0, int|null $cacheReadInputTokens = null, int|null $cacheWriteInputTokens = null, int|null $reasoningTokens = null, int|null $imageInputTokens = null, int|null $imageOutputTokens = null)

Create image generation usage data.

Parameters

int $inputTokens
int $outputTokens
int|null $cacheReadInputTokens

subset of the input tokens read from a prompt cache, or null when unreported

int|null $cacheWriteInputTokens

subset of the input tokens written to a prompt cache, or null when unreported

int|null $reasoningTokens

subset of the output tokens spent on reasoning, or null when unreported

int|null $imageInputTokens

subset of the input tokens billed for images, or null when unreported

int|null $imageOutputTokens

subset of the output tokens billed for generated images, or null when unreported

in Usage at line 24
int totalTokens()

Get the total number of input and output tokens.

Return Value

int

at line 30
array toArray()

Get the instance as an array.

Return Value

array

in Usage at line 43
array jsonSerialize()

Get the JSON serializable representation of the instance.

Return Value

array

in TextUsage at line 33
static TextUsage fromArray(array $data)

Reconstruct an instance from a previously serialized toArray() payload.

Parameters

array $data

Return Value

TextUsage

in TextUsage at line 47
int uncachedInputTokens()

Get the input tokens that were neither read from nor written to a prompt cache.

Return Value

int

in TextUsage at line 55
TextUsage add(TextUsage $usage)

Add the given usage to the current usage and return a new usage instance.

Parameters

TextUsage $usage

Return Value

TextUsage

in TextUsage at line 69
static protected int|null sum(int|null $a, int|null $b)

Sum two optional counts, preserving null when neither was reported.

Parameters

int|null $a
int|null $b

Return Value

int|null