Starting April 29, 2025, Gemini 1.5 Pro and Gemini 1.5 Flash models are not available in projects that have no prior usage of these models, including new projects. For details, see
Model versions and lifecycle .
Send feedback
Class GenerateContentResponse.UsageMetadata.Builder (1.0.0)
Stay organized with collections
Save and categorize content based on your preferences.
public static final class GenerateContentResponse . UsageMetadata . Builder extends GeneratedMessageV3 . Builder<GenerateContentResponse . UsageMetadata . Builder > implements GenerateContentResponse . UsageMetadataOrBuilder
Usage metadata about response(s).
Protobuf type google.cloud.vertexai.v1.GenerateContentResponse.UsageMetadata
Inherited Members
com.google.protobuf.GeneratedMessageV3.Builder.getUnknownFieldSetBuilder()
com.google.protobuf.GeneratedMessageV3.Builder.internalGetMapFieldReflection(int)
com.google.protobuf.GeneratedMessageV3.Builder.internalGetMutableMapFieldReflection(int)
com.google.protobuf.GeneratedMessageV3.Builder.mergeUnknownLengthDelimitedField(int,com.google.protobuf.ByteString)
com.google.protobuf.GeneratedMessageV3.Builder.mergeUnknownVarintField(int,int)
com.google.protobuf.GeneratedMessageV3.Builder.parseUnknownField(com.google.protobuf.CodedInputStream,com.google.protobuf.ExtensionRegistryLite,int)
com.google.protobuf.GeneratedMessageV3.Builder.setUnknownFieldSetBuilder(com.google.protobuf.UnknownFieldSet.Builder)
Static Methods
getDescriptor()
public static final Descriptors . Descriptor getDescriptor ()
Methods
addRepeatedField(Descriptors.FieldDescriptor field, Object value)
public GenerateContentResponse . UsageMetadata . Builder addRepeatedField ( Descriptors . FieldDescriptor field , Object value )
Overrides
build()
public GenerateContentResponse . UsageMetadata build ()
buildPartial()
public GenerateContentResponse . UsageMetadata buildPartial ()
clear()
public GenerateContentResponse . UsageMetadata . Builder clear ()
Overrides
clearCandidatesTokenCount()
public GenerateContentResponse . UsageMetadata . Builder clearCandidatesTokenCount ()
Number of tokens in the response(s).
int32 candidates_token_count = 2;
clearField(Descriptors.FieldDescriptor field)
public GenerateContentResponse . UsageMetadata . Builder clearField ( Descriptors . FieldDescriptor field )
Overrides
clearOneof(Descriptors.OneofDescriptor oneof)
public GenerateContentResponse . UsageMetadata . Builder clearOneof ( Descriptors . OneofDescriptor oneof )
Overrides
clearPromptTokenCount()
public GenerateContentResponse . UsageMetadata . Builder clearPromptTokenCount ()
Number of tokens in the request.
int32 prompt_token_count = 1;
clearTotalTokenCount()
public GenerateContentResponse . UsageMetadata . Builder clearTotalTokenCount ()
int32 total_token_count = 3;
clone()
public GenerateContentResponse . UsageMetadata . Builder clone ()
Overrides
getCandidatesTokenCount()
public int getCandidatesTokenCount ()
Number of tokens in the response(s).
int32 candidates_token_count = 2;
Returns
Type
Description
int
The candidatesTokenCount.
getDefaultInstanceForType()
public GenerateContentResponse . UsageMetadata getDefaultInstanceForType ()
getDescriptorForType()
public Descriptors . Descriptor getDescriptorForType ()
Overrides
getPromptTokenCount()
public int getPromptTokenCount ()
Number of tokens in the request.
int32 prompt_token_count = 1;
Returns
Type
Description
int
The promptTokenCount.
getTotalTokenCount()
public int getTotalTokenCount ()
int32 total_token_count = 3;
Returns
Type
Description
int
The totalTokenCount.
internalGetFieldAccessorTable()
protected GeneratedMessageV3 . FieldAccessorTable internalGetFieldAccessorTable ()
Overrides
isInitialized()
public final boolean isInitialized ()
Overrides
mergeFrom(GenerateContentResponse.UsageMetadata other)
public GenerateContentResponse . UsageMetadata . Builder mergeFrom ( GenerateContentResponse . UsageMetadata other )
mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
public GenerateContentResponse . UsageMetadata . Builder mergeFrom ( CodedInputStream input , ExtensionRegistryLite extensionRegistry )
Overrides
mergeFrom(Message other)
public GenerateContentResponse . UsageMetadata . Builder mergeFrom ( Message other )
Parameter
Name
Description
other
Message
Overrides
mergeUnknownFields(UnknownFieldSet unknownFields)
public final GenerateContentResponse . UsageMetadata . Builder mergeUnknownFields ( UnknownFieldSet unknownFields )
Overrides
setCandidatesTokenCount(int value)
public GenerateContentResponse . UsageMetadata . Builder setCandidatesTokenCount ( int value )
Number of tokens in the response(s).
int32 candidates_token_count = 2;
Parameter
Name
Description
value
int
The candidatesTokenCount to set.
setField(Descriptors.FieldDescriptor field, Object value)
public GenerateContentResponse . UsageMetadata . Builder setField ( Descriptors . FieldDescriptor field , Object value )
Overrides
setPromptTokenCount(int value)
public GenerateContentResponse . UsageMetadata . Builder setPromptTokenCount ( int value )
Number of tokens in the request.
int32 prompt_token_count = 1;
Parameter
Name
Description
value
int
The promptTokenCount to set.
setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
public GenerateContentResponse . UsageMetadata . Builder setRepeatedField ( Descriptors . FieldDescriptor field , int index , Object value )
Overrides
setTotalTokenCount(int value)
public GenerateContentResponse . UsageMetadata . Builder setTotalTokenCount ( int value )
int32 total_token_count = 3;
Parameter
Name
Description
value
int
The totalTokenCount to set.
setUnknownFields(UnknownFieldSet unknownFields)
public final GenerateContentResponse . UsageMetadata . Builder setUnknownFields ( UnknownFieldSet unknownFields )
Overrides
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-02 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-02 UTC."],[],[]]