Usage metadata for a message, such as token counts.
public class UsageMetadataUsage metadata for a message, such as token counts. This is a standard representation of token usage that is consistent across models. Example:
{
"input_tokens": 350,
"output_tokens": 240,
"total_tokens": 590,
"input_token_details": {
"audio": 10,
"cache_creation": 200,
"cache_read": 100,
},
"output_token_details": {
"audio": 10,
"reasoning": 200,
},
}
"Behavior changed in 0.3.9" Added input_token_details and output_token_details.
unexpectedly missing or null (e.g.
unexpectedly missing or null (e.g.
unexpectedly missing or null (e.g.
Breakdown of input token counts.
Breakdown of output token counts.
Returns the raw JSON value of [inputTokens].
Returns the raw JSON value of [outputTokens].
Returns the raw JSON value of [totalTokens].
Returns the raw JSON value of [inputTokenDetails].
Returns the raw JSON value of [outputTokenDetails].
Returns a mutable builder for constructing an instance of [UsageMetadata].
unexpectedly missing or null (e.g.
unexpectedly missing or null (e.g.
unexpectedly missing or null (e.g.
unexpectedly missing or null (e.g.
unexpectedly missing or null (e.g.
unexpectedly missing or null (e.g.
Breakdown of input token counts.
Breakdown of input token counts.
Breakdown of output token counts.
Breakdown of output token counts.
Returns an immutable instance of [UsageMetadata].
the server responded with an unexpected value)..
the server responded with an unexpected value)..
the server responded with an unexpected value)..
Returns the raw JSON value of [audio].
Returns the raw JSON value of [cacheCreation].
Returns the raw JSON value of [cacheRead].
Returns a mutable builder for constructing an instance of [UsageMetadata].
the server responded with an unexpected value)..
the server responded with an unexpected value)..
the server responded with an unexpected value)..
the server responded with an unexpected value)..
the server responded with an unexpected value)..
the server responded with an unexpected value)..
Returns an immutable instance of [UsageMetadata].