Class UsageMetadata
-
- All Implemented Interfaces:
public abstract class UsageMetadata extends JsonSerializable
Usage metadata about response(s).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public abstract classUsageMetadata.BuilderBuilder for UsageMetadata.
-
Field Summary
Fields Modifier and Type Field Description public final static StringMAX_READ_LENGTH_PROPERTY
-
Constructor Summary
Constructors Constructor Description UsageMetadata()
-
Method Summary
Modifier and Type Method Description abstract Optional<Integer>promptTokenCount()Number of tokens in the prompt. abstract Optional<Integer>cachedContentTokenCount()Number of tokens in the cached part of the prompt (the cached content). abstract Optional<Integer>responseTokenCount()Total number of tokens across all the generated response candidates. abstract Optional<Integer>toolUsePromptTokenCount()Number of tokens present in tool-use prompt(s). abstract Optional<Integer>thoughtsTokenCount()Number of tokens of thoughts for thinking models. abstract Optional<Integer>totalTokenCount()Total token count for prompt, response candidates, and tool-use prompts(if present). abstract Optional<List<ModalityTokenCount>>promptTokensDetails()List of modalities that were processed in the request input. abstract Optional<List<ModalityTokenCount>>cacheTokensDetails()List of modalities that were processed in the cache input. abstract Optional<List<ModalityTokenCount>>responseTokensDetails()List of modalities that were returned in the response. abstract Optional<List<ModalityTokenCount>>toolUsePromptTokensDetails()List of modalities that were processed in the tool-use prompt. abstract Optional<TrafficType>trafficType()Traffic type. static UsageMetadata.Builderbuilder()Instantiates a builder for UsageMetadata. abstract UsageMetadata.BuildertoBuilder()Creates a builder with the same values as this instance. static UsageMetadatafromJson(String jsonString)Deserializes a JSON string to a UsageMetadata object. -
Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
promptTokenCount
abstract Optional<Integer> 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
abstract Optional<Integer> cachedContentTokenCount()
Number of tokens in the cached part of the prompt (the cached content).
-
responseTokenCount
abstract Optional<Integer> responseTokenCount()
Total number of tokens across all the generated response candidates.
-
toolUsePromptTokenCount
abstract Optional<Integer> toolUsePromptTokenCount()
Number of tokens present in tool-use prompt(s).
-
thoughtsTokenCount
abstract Optional<Integer> thoughtsTokenCount()
Number of tokens of thoughts for thinking models.
-
totalTokenCount
abstract Optional<Integer> totalTokenCount()
Total token count for prompt, response candidates, and tool-use prompts(if present).
-
promptTokensDetails
abstract Optional<List<ModalityTokenCount>> promptTokensDetails()
List of modalities that were processed in the request input.
-
cacheTokensDetails
abstract Optional<List<ModalityTokenCount>> cacheTokensDetails()
List of modalities that were processed in the cache input.
-
responseTokensDetails
abstract Optional<List<ModalityTokenCount>> responseTokensDetails()
List of modalities that were returned in the response.
-
toolUsePromptTokensDetails
abstract Optional<List<ModalityTokenCount>> toolUsePromptTokensDetails()
List of modalities that were processed in the tool-use prompt.
-
trafficType
abstract Optional<TrafficType> trafficType()
Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota.
-
builder
static UsageMetadata.Builder builder()
Instantiates a builder for UsageMetadata.
-
toBuilder
abstract UsageMetadata.Builder toBuilder()
Creates a builder with the same values as this instance.
-
fromJson
static UsageMetadata fromJson(String jsonString)
Deserializes a JSON string to a UsageMetadata object.
-
-
-
-