Usage

@Serializable
class Usage(val completionTokens: Int, val promptTokens: Int, val promptCacheHitTokens: Int? = null, val promptCacheMissTokens: Int? = null, val promptTokensDetails: PromptTokensDetails? = null, val totalTokens: Int, val completionTokensDetails: CompletionTokenDetails? = null)

Token usage statistics for a single chat or FIM request.

For streamed responses the statistics ride on the last content chunk — the one whose single choice carries no new content and a non-null finish_reason — instead of a separate usage-only chunk; see ChatCompletionChunk.usage and StreamOptions.

Constructors

Link copied to clipboard
constructor(completionTokens: Int, promptTokens: Int, promptCacheHitTokens: Int? = null, promptCacheMissTokens: Int? = null, promptTokensDetails: PromptTokensDetails? = null, totalTokens: Int, completionTokensDetails: CompletionTokenDetails? = null)

Properties

Link copied to clipboard

Number of tokens in the generated completion.

Link copied to clipboard

Breakdown of how completionTokens was spent — in particular the tokens spent on reasoning in thinking mode.

Link copied to clipboard

Number of prompt tokens served from the context cache, or null when caching does not apply.

Link copied to clipboard

Number of prompt tokens not served from the context cache, or null when caching does not apply.

Link copied to clipboard

Number of tokens in the prompt, equal to promptCacheHitTokens + promptCacheMissTokens.

Link copied to clipboard

Breakdown of promptTokens under the OpenAI-compatible prompt_tokens_details key. The current API reference leaves it out, but live responses still carry it alongside promptCacheHitTokens / promptCacheMissTokens, so it is kept and stays nullable.

Link copied to clipboard

Total tokens billed for the request (prompt + completion).

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String