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 classBuilder for GenerateContentResponse. -
Field Summary
Fields inherited from class com.google.genai.JsonSerializable
objectMapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Instantiates a builder for GenerateContentResponse.Response variations returned by the model.@Nullable StringReturns the code execution result in the response.@Nullable StringReturns the executable code in the response.static GenerateContentResponseDeserializes 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.@Nullable Stringtext()Returns the concatenation of all text parts in the first candidate of the response.abstract GenerateContentResponse.BuilderCreates 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
fromJsonNode, fromJsonString, toJson, toJsonNode, toJsonString
-
Constructor Details
-
GenerateContentResponse
public GenerateContentResponse()
-
-
Method Details
-
candidates
Response variations returned by the model. -
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
- Throws:
IllegalArgumentException- if the response finishes unexpectedly.
-
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.
- Throws:
IllegalArgumentException- if the response has non-text parts or finishes unexpectedly.
-
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.
-