Package com.google.genai.types
Class Candidate
java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.Candidate
A response candidate generated from the model.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.google.genai.JsonSerializable
MAX_READ_LENGTH_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOutput only.static Candidate.Builderbuilder()Instantiates a builder for Candidate.abstract Optional<CitationMetadata>Source attribution of the generated content.content()Contains the multi-part content of the response.Describes the reason the model stopped generating tokens.abstract Optional<FinishReason>The reason why the model stopped generating tokens.static CandidateDeserializes a JSON string to a Candidate object.abstract Optional<GroundingMetadata>Output only.index()Output only.abstract Optional<LogprobsResult>Output only.abstract Optional<List<SafetyRating>>Output only.abstract Candidate.BuilderCreates a builder with the same values as this instance.Number of tokens for this candidate.abstract Optional<UrlContextMetadata>Output only.Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString
-
Constructor Details
-
Candidate
public Candidate()
-
-
Method Details
-
content
Contains the multi-part content of the response. -
citationMetadata
Source attribution of the generated content. -
finishMessage
Describes the reason the model stopped generating tokens. -
tokenCount
Number of tokens for this candidate. -
finishReason
The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens. -
groundingMetadata
Output only. Metadata returned when grounding is enabled. It contains the sources used to ground the generated content. -
avgLogprobs
Output only. The average log probability of the tokens in this candidate. This is a length-normalized score that can be used to compare the quality of candidates of different lengths. A higher average log probability suggests a more confident and coherent response. -
index
Output only. The 0-based index of this candidate in the list of generated responses. This is useful for distinguishing between multiple candidates when `candidate_count` > 1. -
logprobsResult
Output only. The detailed log probability information for the tokens in this candidate. This is useful for debugging, understanding model uncertainty, and identifying potential "hallucinations". -
safetyRatings
Output only. A list of ratings for the safety of a response candidate. There is at most one rating per category. -
urlContextMetadata
Output only. Metadata returned when the model uses the `url_context` tool to get information from a user-provided URL. -
builder
Instantiates a builder for Candidate. -
toBuilder
Creates a builder with the same values as this instance. -
fromJson
Deserializes a JSON string to a Candidate object.
-