Interface Candidate

A response candidate generated from the model.

interface Candidate {
    avgLogprobs?: number;
    citationMetadata?: CitationMetadata;
    content?: Content;
    finishMessage?: string;
    finishReason?: FinishReason;
    groundingMetadata?: GroundingMetadata;
    index?: number;
    logprobsResult?: LogprobsResult;
    safetyRatings?: SafetyRating[];
    tokenCount?: number;
    urlContextMetadata?: UrlContextMetadata;
}

Properties

avgLogprobs?: number

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.

citationMetadata?: CitationMetadata

Source attribution of the generated content.

content?: Content

Contains the multi-part content of the response.

finishMessage?: string

Describes the reason the model stopped generating tokens.

finishReason?: FinishReason

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

groundingMetadata?: GroundingMetadata

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

index?: number

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?: 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?: SafetyRating[]

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

tokenCount?: number

Number of tokens for this candidate.

urlContextMetadata?: UrlContextMetadata

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