ModalityTokenCount

Represents a breakdown of token usage by modality.

This message is used in [CountTokensResponse][google.cloud.aiplatform.master.CountTokensResponse] andGenerateContentResponse.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.

Fields
modalityenum (Modality)

The modality that this token count applies to.

tokenCountinteger

The number of tokens counted for this modality.

JSON representation
{"modality":enum (Modality),"tokenCount":integer}

Modality

The modality of aPart of aContent message. A modality is the type of media, such as an image or a video. It is used to categorize the content of aPart for token counting purposes.

Enums
MODALITY_UNSPECIFIEDWhen a modality is not specified, it is treated asTEXT.
TEXTThePart contains plain text.
IMAGEThePart contains an image.
VIDEOThePart contains a video.
AUDIOThePart contains audio.
DOCUMENTThePart contains a document, such as a PDF.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-17 UTC.