Class Candidate

java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.Candidate

public abstract class Candidate extends JsonSerializable
A response candidate generated from the model.
  • Constructor Details

    • Candidate

      public Candidate()
  • Method Details

    • content

      public abstract Optional<Content> content()
      Contains the multi-part content of the response.
    • citationMetadata

      public abstract Optional<CitationMetadata> citationMetadata()
      Source attribution of the generated content.
    • finishMessage

      public abstract Optional<String> finishMessage()
      Describes the reason the model stopped generating tokens.
    • tokenCount

      public abstract Optional<Integer> tokenCount()
      Number of tokens for this candidate.
    • finishReason

      public abstract Optional<FinishReason> finishReason()
      The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens.
    • urlContextMetadata

      public abstract Optional<UrlContextMetadata> urlContextMetadata()
      Metadata related to url context retrieval tool.
    • avgLogprobs

      public abstract Optional<Double> avgLogprobs()
      Output only. Average log probability score of the candidate.
    • groundingMetadata

      public abstract Optional<GroundingMetadata> groundingMetadata()
      Output only. Metadata specifies sources used to ground generated content.
    • index

      public abstract Optional<Integer> index()
      Output only. Index of the candidate.
    • logprobsResult

      public abstract Optional<LogprobsResult> logprobsResult()
      Output only. Log-likelihood scores for the response tokens and top tokens
    • safetyRatings

      public abstract Optional<List<SafetyRating>> safetyRatings()
      Output only. List of ratings for the safety of a response candidate. There is at most one rating per category.
    • builder

      public static Candidate.Builder builder()
      Instantiates a builder for Candidate.
    • toBuilder

      public abstract Candidate.Builder toBuilder()
      Creates a builder with the same values as this instance.
    • fromJson

      public static Candidate fromJson(String jsonString)
      Deserializes a JSON string to a Candidate object.