Class GenerateContentResponse
-
- All Implemented Interfaces:
public abstract class GenerateContentResponse extends JsonSerializable
Response message for PredictionService.GenerateContent.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public abstract classGenerateContentResponse.BuilderBuilder for GenerateContentResponse.
-
Field Summary
Fields Modifier and Type Field Description public final static StringMAX_READ_LENGTH_PROPERTY
-
Constructor Summary
Constructors Constructor Description GenerateContentResponse()
-
Method Summary
Modifier and Type Method Description abstract Optional<HttpResponse>sdkHttpResponse()Used to retain the full HTTP response. abstract Optional<List<Candidate>>candidates()Response variations returned by the model. abstract Optional<Instant>createTime()Timestamp when the request is made to the server. abstract Optional<List<Content>>automaticFunctionCallingHistory()The history of automatic function calling. abstract Optional<String>modelVersion()Output only. abstract Optional<GenerateContentResponsePromptFeedback>promptFeedback()Output only. abstract Optional<String>responseId()Output only. abstract Optional<GenerateContentResponseUsageMetadata>usageMetadata()Usage metadata about the response(s). abstract Optional<ModelStatus>modelStatus()Output only. static GenerateContentResponse.Builderbuilder()Instantiates a builder for GenerateContentResponse. abstract GenerateContentResponse.BuildertoBuilder()Creates a builder with the same values as this instance. static GenerateContentResponsefromJson(String jsonString)Deserializes a JSON string to a GenerateContentResponse object. ImmutableList<Part>parts()Returns the list of parts in the first candidate of the response. Stringtext()Returns the concatenation of all text parts in the first candidate of the response. ImmutableList<FunctionCall>functionCalls()Returns the list of function calls in the response. StringexecutableCode()Returns the executable code in the response. StringcodeExecutionResult()Returns the code execution result in the response. FinishReasonfinishReason()Gets the finish reason in a GenerateContentResponse. voidcheckFinishReason()Throws an exception if the response finishes unexpectedly. -
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
-
sdkHttpResponse
abstract Optional<HttpResponse> sdkHttpResponse()
Used to retain the full HTTP response.
-
candidates
abstract Optional<List<Candidate>> candidates()
Response variations returned by the model.
-
createTime
abstract Optional<Instant> createTime()
Timestamp when the request is made to the server.
-
automaticFunctionCallingHistory
abstract Optional<List<Content>> automaticFunctionCallingHistory()
The history of automatic function calling.
-
modelVersion
abstract Optional<String> modelVersion()
Output only. The model version used to generate the response.
-
promptFeedback
abstract Optional<GenerateContentResponsePromptFeedback> 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.
-
responseId
abstract Optional<String> responseId()
Output only. response_id is used to identify each response. It is the encoding of the event_id.
-
usageMetadata
abstract Optional<GenerateContentResponseUsageMetadata> usageMetadata()
Usage metadata about the response(s).
-
modelStatus
abstract Optional<ModelStatus> modelStatus()
Output only. The current model status of this model. This field is not supported in Vertex AI.
-
builder
static GenerateContentResponse.Builder builder()
Instantiates a builder for GenerateContentResponse.
-
toBuilder
abstract GenerateContentResponse.Builder toBuilder()
Creates a builder with the same values as this instance.
-
fromJson
static GenerateContentResponse fromJson(String jsonString)
Deserializes a JSON string to a GenerateContentResponse object.
-
parts
@Nullable() ImmutableList<Part> 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
@Nullable() String 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
@Nullable() ImmutableList<FunctionCall> 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
@Nullable() String 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
@Nullable() String 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
FinishReason finishReason()
Gets the finish reason in a GenerateContentResponse.
-
checkFinishReason
@InternalApi() void checkFinishReason()
Throws an exception if the response finishes unexpectedly.
-
-
-
-