Package com.google.genai.types
Class UsageMetadata
java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.UsageMetadata
Usage metadata about response(s).
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic UsageMetadata.Builder
builder()
Instantiates a builder for UsageMetadata.Number of tokens in the cached part of the prompt (the cached content).abstract Optional<List<ModalityTokenCount>>
List of modalities that were processed in the cache input.static UsageMetadata
Deserializes a JSON string to a UsageMetadata object.Number of tokens in the prompt.abstract Optional<List<ModalityTokenCount>>
List of modalities that were processed in the request input.Total number of tokens across all the generated response candidates.abstract Optional<List<ModalityTokenCount>>
List of modalities that were returned in the response.Number of tokens of thoughts for thinking models.abstract UsageMetadata.Builder
Creates a builder with the same values as this instance.Number of tokens present in tool-use prompt(s).abstract Optional<List<ModalityTokenCount>>
List of modalities that were processed in the tool-use prompt.Total token count for prompt, response candidates, and tool-use prompts(if present).abstract Optional<TrafficType>
Traffic type.Methods inherited from class com.google.genai.JsonSerializable
fromJsonString, toJson
-
Constructor Details
-
UsageMetadata
public UsageMetadata()
-
-
Method Details
-
promptTokenCount
Number of tokens in the prompt. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content. -
cachedContentTokenCount
Number of tokens in the cached part of the prompt (the cached content). -
responseTokenCount
Total number of tokens across all the generated response candidates. -
toolUsePromptTokenCount
Number of tokens present in tool-use prompt(s). -
thoughtsTokenCount
Number of tokens of thoughts for thinking models. -
totalTokenCount
Total token count for prompt, response candidates, and tool-use prompts(if present). -
promptTokensDetails
List of modalities that were processed in the request input. -
cacheTokensDetails
List of modalities that were processed in the cache input. -
responseTokensDetails
List of modalities that were returned in the response. -
toolUsePromptTokensDetails
List of modalities that were processed in the tool-use prompt. -
trafficType
Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota. -
builder
Instantiates a builder for UsageMetadata. -
toBuilder
Creates a builder with the same values as this instance. -
fromJson
Deserializes a JSON string to a UsageMetadata object.
-