Candidate

@Serializable
data class Candidate(val content: Content? = null, val citationMetadata: CitationMetadata? = null, val finishMessage: String? = null, val tokenCount: Int? = null, val finishReason: FinishReason? = null, val groundingMetadata: GroundingMetadata? = null, val avgLogprobs: Double? = null, val index: Int? = null, val logprobsResult: LogprobsResult? = null, val safetyRatings: List<SafetyRating>? = null, val urlContextMetadata: UrlContextMetadata? = null)

A response candidate generated from the model.

Constructors

Link copied to clipboard
constructor(content: Content? = null, citationMetadata: CitationMetadata? = null, finishMessage: String? = null, tokenCount: Int? = null, finishReason: FinishReason? = null, groundingMetadata: GroundingMetadata? = null, avgLogprobs: Double? = null, index: Int? = null, logprobsResult: LogprobsResult? = null, safetyRatings: List<SafetyRating>? = null, urlContextMetadata: UrlContextMetadata? = null)

Properties

Link copied to clipboard
val avgLogprobs: Double? = null

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.

Link copied to clipboard

Source attribution of the generated content.

Link copied to clipboard
val content: Content? = null

Contains the multi-part content of the response.

Link copied to clipboard
val finishMessage: String? = null

Describes the reason the model stopped generating tokens.

Link copied to clipboard

The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens.

Link copied to clipboard

Output only. Metadata returned when grounding is enabled. It contains the sources used to ground the generated content.

Link copied to clipboard
val index: Int? = null

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.

Link copied to clipboard

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".

Link copied to clipboard

Output only. A list of ratings for the safety of a response candidate. There is at most one rating per category.

Link copied to clipboard
val tokenCount: Int? = null

Number of tokens for this candidate.

Link copied to clipboard

Output only. Metadata returned when the model uses the url_context tool to get information from a user-provided URL.