Package com.google.genai.types
Class ModalityTokenCount
java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.ModalityTokenCount
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for ModalityTokenCount. -
Field Summary
Fields inherited from class com.google.genai.JsonSerializable
MAX_READ_LENGTH_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ModalityTokenCount.Builderbuilder()Instantiates a builder for ModalityTokenCount.static ModalityTokenCountDeserializes a JSON string to a ModalityTokenCount object.abstract Optional<MediaModality>modality()The modality that this token count applies to.abstract ModalityTokenCount.BuilderCreates a builder with the same values as this instance.The number of tokens counted for this modality.Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString
-
Constructor Details
-
ModalityTokenCount
public ModalityTokenCount()
-
-
Method Details
-
modality
The modality that this token count applies to. -
tokenCount
The number of tokens counted for this modality. -
builder
Instantiates a builder for ModalityTokenCount. -
toBuilder
Creates a builder with the same values as this instance. -
fromJson
Deserializes a JSON string to a ModalityTokenCount object.
-