ModalityTokenCount

@Serializable
data class ModalityTokenCount(val modality: MediaModality? = null, val tokenCount: Int? = null)

Represents a breakdown of token usage by modality. This message is used in CountTokensResponse and GenerateContentResponse.UsageMetadata to provide a detailed view of how many tokens are used by each modality (e.g., text, image, video) in a request. This is particularly useful for multimodal models, allowing you to track and manage token consumption for billing and quota purposes.

Constructors

Link copied to clipboard
constructor(modality: MediaModality? = null, tokenCount: Int? = null)

Properties

Link copied to clipboard
val modality: MediaModality? = null

The modality that this token count applies to.

Link copied to clipboard
val tokenCount: Int? = null

The number of tokens counted for this modality.