Package com.google.genai.types
Class GenerateContentResponse
java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.GenerateContentResponse
Response message for PredictionService.GenerateContent.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder for GenerateContentResponse. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Instantiates a builder for GenerateContentResponse.Response variations returned by the model.void
Throws an exception if the response finishes unexpectedly.@Nullable String
Returns the code execution result in the response.Timestamp when the request is made to the server.@Nullable String
Returns the executable code in the response.Gets the finish reason in a GenerateContentResponse.static GenerateContentResponse
Deserializes a JSON string to a GenerateContentResponse object.@Nullable com.google.common.collect.ImmutableList<FunctionCall>
Returns the list of function calls in the response.Output only.@Nullable com.google.common.collect.ImmutableList<Part>
parts()
Returns the list of parts in the first candidate of the response.Output only.Identifier for each response.@Nullable String
text()
Returns the concatenation of all text parts in the first candidate of the response.abstract GenerateContentResponse.Builder
Creates a builder with the same values as this instance.abstract Optional<GenerateContentResponseUsageMetadata>
Usage metadata about the response(s).Methods inherited from class com.google.genai.JsonSerializable
fromJsonString, toJson
-
Constructor Details
-
GenerateContentResponse
public GenerateContentResponse()
-
-
Method Details
-
candidates
Response variations returned by the model. -
createTime
Timestamp when the request is made to the server. -
responseId
Identifier for each response. -
modelVersion
Output only. The model version used to generate the response. -
promptFeedback
Output only. Content filter results for a prompt sent in the request. Note: Sent only in the first stream chunk. Only happens when no candidates were generated due to content violations. -
usageMetadata
Usage metadata about the response(s). -
builder
Instantiates a builder for GenerateContentResponse. -
toBuilder
Creates a builder with the same values as this instance. -
fromJson
Deserializes a JSON string to a GenerateContentResponse object. -
parts
Returns the list of parts in the first candidate of the response.Returns null if there is no candidate or no content in the first candidate
-
text
Returns the concatenation of all text parts in the first candidate of the response.Returns null if there is no candidate, no content in the first candidate, or no parts in the content.
-
functionCalls
Returns the list of function calls in the response.Returns null if there is no candidate, no content in the first candidate, or no parts in the content.
-
executableCode
Returns the executable code in the response.Returns null if there is no candidate, no content in the first candidate, or no parts in the content, or no executable code in the parts.
-
codeExecutionResult
Returns the code execution result in the response.Returns null if there is no candidate, no content in the first candidate, or no parts in the content, or no code execution result in the parts.
-
finishReason
Gets the finish reason in a GenerateContentResponse. -
checkFinishReason
@InternalApi public void checkFinishReason()Throws an exception if the response finishes unexpectedly.
-