Class GenerationConfig.Builder

java.lang.Object
com.google.genai.types.GenerationConfig.Builder
Enclosing class:
GenerationConfig

public abstract static class GenerationConfig.Builder extends Object
Builder for GenerationConfig.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • modelSelectionConfig

      public abstract GenerationConfig.Builder modelSelectionConfig(ModelSelectionConfig modelSelectionConfig)
      Setter for modelSelectionConfig.

      modelSelectionConfig: Optional. Config for model selection.

    • modelSelectionConfig

      @CanIgnoreReturnValue public GenerationConfig.Builder modelSelectionConfig(ModelSelectionConfig.Builder modelSelectionConfigBuilder)
      Setter for modelSelectionConfig builder.

      modelSelectionConfig: Optional. Config for model selection.

    • clearModelSelectionConfig

      @CanIgnoreReturnValue public GenerationConfig.Builder clearModelSelectionConfig()
      Clears the value of modelSelectionConfig field.
    • responseJsonSchema

      public abstract GenerationConfig.Builder responseJsonSchema(Object responseJsonSchema)
      Setter for responseJsonSchema.

      responseJsonSchema: Output schema of the generated response. This is an alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/).

    • clearResponseJsonSchema

      @CanIgnoreReturnValue public GenerationConfig.Builder clearResponseJsonSchema()
      Clears the value of responseJsonSchema field.
    • audioTimestamp

      public abstract GenerationConfig.Builder audioTimestamp(boolean audioTimestamp)
      Setter for audioTimestamp.

      audioTimestamp: Optional. If enabled, audio timestamp will be included in the request to the model. This field is not supported in Gemini API.

    • clearAudioTimestamp

      @CanIgnoreReturnValue public GenerationConfig.Builder clearAudioTimestamp()
      Clears the value of audioTimestamp field.
    • candidateCount

      public abstract GenerationConfig.Builder candidateCount(Integer candidateCount)
      Setter for candidateCount.

      candidateCount: Optional. Number of candidates to generate.

    • clearCandidateCount

      @CanIgnoreReturnValue public GenerationConfig.Builder clearCandidateCount()
      Clears the value of candidateCount field.
    • enableAffectiveDialog

      public abstract GenerationConfig.Builder enableAffectiveDialog(boolean enableAffectiveDialog)
      Setter for enableAffectiveDialog.

      enableAffectiveDialog: Optional. If enabled, the model will detect emotions and adapt its responses accordingly. This field is not supported in Gemini API.

    • clearEnableAffectiveDialog

      @CanIgnoreReturnValue public GenerationConfig.Builder clearEnableAffectiveDialog()
      Clears the value of enableAffectiveDialog field.
    • frequencyPenalty

      public abstract GenerationConfig.Builder frequencyPenalty(Float frequencyPenalty)
      Setter for frequencyPenalty.

      frequencyPenalty: Optional. Frequency penalties.

    • clearFrequencyPenalty

      @CanIgnoreReturnValue public GenerationConfig.Builder clearFrequencyPenalty()
      Clears the value of frequencyPenalty field.
    • logprobs

      public abstract GenerationConfig.Builder logprobs(Integer logprobs)
      Setter for logprobs.

      logprobs: Optional. Logit probabilities.

    • clearLogprobs

      @CanIgnoreReturnValue public GenerationConfig.Builder clearLogprobs()
      Clears the value of logprobs field.
    • maxOutputTokens

      public abstract GenerationConfig.Builder maxOutputTokens(Integer maxOutputTokens)
      Setter for maxOutputTokens.

      maxOutputTokens: Optional. The maximum number of output tokens to generate per message.

    • clearMaxOutputTokens

      @CanIgnoreReturnValue public GenerationConfig.Builder clearMaxOutputTokens()
      Clears the value of maxOutputTokens field.
    • mediaResolution

      public abstract GenerationConfig.Builder mediaResolution(MediaResolution mediaResolution)
      Setter for mediaResolution.

      mediaResolution: Optional. If specified, the media resolution specified will be used.

    • clearMediaResolution

      @CanIgnoreReturnValue public GenerationConfig.Builder clearMediaResolution()
      Clears the value of mediaResolution field.
    • mediaResolution

      @CanIgnoreReturnValue public GenerationConfig.Builder mediaResolution(MediaResolution.Known knownType)
      Setter for mediaResolution given a known enum.

      mediaResolution: Optional. If specified, the media resolution specified will be used.

    • mediaResolution

      @CanIgnoreReturnValue public GenerationConfig.Builder mediaResolution(String mediaResolution)
      Setter for mediaResolution given a string.

      mediaResolution: Optional. If specified, the media resolution specified will be used.

    • presencePenalty

      public abstract GenerationConfig.Builder presencePenalty(Float presencePenalty)
      Setter for presencePenalty.

      presencePenalty: Optional. Positive penalties.

    • clearPresencePenalty

      @CanIgnoreReturnValue public GenerationConfig.Builder clearPresencePenalty()
      Clears the value of presencePenalty field.
    • responseLogprobs

      public abstract GenerationConfig.Builder responseLogprobs(boolean responseLogprobs)
      Setter for responseLogprobs.

      responseLogprobs: Optional. If true, export the logprobs results in response.

    • clearResponseLogprobs

      @CanIgnoreReturnValue public GenerationConfig.Builder clearResponseLogprobs()
      Clears the value of responseLogprobs field.
    • responseMimeType

      public abstract GenerationConfig.Builder responseMimeType(String responseMimeType)
      Setter for responseMimeType.

      responseMimeType: Optional. Output response mimetype of the generated candidate text. Supported mimetype: - `text/plain`: (default) Text output. - `application/json`: JSON response in the candidates. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature.

    • clearResponseMimeType

      @CanIgnoreReturnValue public GenerationConfig.Builder clearResponseMimeType()
      Clears the value of responseMimeType field.
    • responseModalities

      public abstract GenerationConfig.Builder responseModalities(List<Modality> responseModalities)
      Setter for responseModalities.

      responseModalities: Optional. The modalities of the response.

    • responseModalities

      @CanIgnoreReturnValue public GenerationConfig.Builder responseModalities(Modality... responseModalities)
      Setter for responseModalities.

      responseModalities: Optional. The modalities of the response.

    • clearResponseModalities

      @CanIgnoreReturnValue public GenerationConfig.Builder clearResponseModalities()
      Clears the value of responseModalities field.
    • responseModalities

      @CanIgnoreReturnValue public GenerationConfig.Builder responseModalities(String... responseModalities)
      Setter for responseModalities given a varargs of strings.

      responseModalities: Optional. The modalities of the response.

    • responseModalities

      @CanIgnoreReturnValue public GenerationConfig.Builder responseModalities(Modality.Known... knownTypes)
      Setter for responseModalities given a varargs of known enums.

      responseModalities: Optional. The modalities of the response.

    • responseModalitiesFromKnown

      @CanIgnoreReturnValue public GenerationConfig.Builder responseModalitiesFromKnown(List<Modality.Known> knownTypes)
      Setter for responseModalities given a list of known enums.

      responseModalities: Optional. The modalities of the response.

    • responseModalitiesFromString

      @CanIgnoreReturnValue public GenerationConfig.Builder responseModalitiesFromString(List<String> responseModalities)
      Setter for responseModalities given a list of strings.

      responseModalities: Optional. The modalities of the response.

    • responseSchema

      public abstract GenerationConfig.Builder responseSchema(Schema responseSchema)
      Setter for responseSchema.

      responseSchema: Optional. The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON response.

    • responseSchema

      @CanIgnoreReturnValue public GenerationConfig.Builder responseSchema(Schema.Builder responseSchemaBuilder)
      Setter for responseSchema builder.

      responseSchema: Optional. The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON response.

    • clearResponseSchema

      @CanIgnoreReturnValue public GenerationConfig.Builder clearResponseSchema()
      Clears the value of responseSchema field.
    • routingConfig

      public abstract GenerationConfig.Builder routingConfig(GenerationConfigRoutingConfig routingConfig)
      Setter for routingConfig.

      routingConfig: Optional. Routing configuration. This field is not supported in Gemini API.

    • routingConfig

      @CanIgnoreReturnValue public GenerationConfig.Builder routingConfig(GenerationConfigRoutingConfig.Builder routingConfigBuilder)
      Setter for routingConfig builder.

      routingConfig: Optional. Routing configuration. This field is not supported in Gemini API.

    • clearRoutingConfig

      @CanIgnoreReturnValue public GenerationConfig.Builder clearRoutingConfig()
      Clears the value of routingConfig field.
    • seed

      public abstract GenerationConfig.Builder seed(Integer seed)
      Setter for seed.

      seed: Optional. Seed.

    • clearSeed

      @CanIgnoreReturnValue public GenerationConfig.Builder clearSeed()
      Clears the value of seed field.
    • speechConfig

      public abstract GenerationConfig.Builder speechConfig(SpeechConfig speechConfig)
      Setter for speechConfig.

      speechConfig: Optional. The speech generation config.

    • speechConfig

      @CanIgnoreReturnValue public GenerationConfig.Builder speechConfig(SpeechConfig.Builder speechConfigBuilder)
      Setter for speechConfig builder.

      speechConfig: Optional. The speech generation config.

    • clearSpeechConfig

      @CanIgnoreReturnValue public GenerationConfig.Builder clearSpeechConfig()
      Clears the value of speechConfig field.
    • stopSequences

      public abstract GenerationConfig.Builder stopSequences(List<String> stopSequences)
      Setter for stopSequences.

      stopSequences: Optional. Stop sequences.

    • stopSequences

      @CanIgnoreReturnValue public GenerationConfig.Builder stopSequences(String... stopSequences)
      Setter for stopSequences.

      stopSequences: Optional. Stop sequences.

    • clearStopSequences

      @CanIgnoreReturnValue public GenerationConfig.Builder clearStopSequences()
      Clears the value of stopSequences field.
    • temperature

      public abstract GenerationConfig.Builder temperature(Float temperature)
      Setter for temperature.

      temperature: Optional. Controls the randomness of predictions.

    • clearTemperature

      @CanIgnoreReturnValue public GenerationConfig.Builder clearTemperature()
      Clears the value of temperature field.
    • thinkingConfig

      public abstract GenerationConfig.Builder thinkingConfig(ThinkingConfig thinkingConfig)
      Setter for thinkingConfig.

      thinkingConfig: Optional. Config for thinking features. An error will be returned if this field is set for models that don't support thinking.

    • thinkingConfig

      @CanIgnoreReturnValue public GenerationConfig.Builder thinkingConfig(ThinkingConfig.Builder thinkingConfigBuilder)
      Setter for thinkingConfig builder.

      thinkingConfig: Optional. Config for thinking features. An error will be returned if this field is set for models that don't support thinking.

    • clearThinkingConfig

      @CanIgnoreReturnValue public GenerationConfig.Builder clearThinkingConfig()
      Clears the value of thinkingConfig field.
    • topK

      public abstract GenerationConfig.Builder topK(Float topK)
      Setter for topK.

      topK: Optional. If specified, top-k sampling will be used.

    • clearTopK

      @CanIgnoreReturnValue public GenerationConfig.Builder clearTopK()
      Clears the value of topK field.
    • topP

      public abstract GenerationConfig.Builder topP(Float topP)
      Setter for topP.

      topP: Optional. If specified, nucleus sampling will be used.

    • clearTopP

      @CanIgnoreReturnValue public GenerationConfig.Builder clearTopP()
      Clears the value of topP field.
    • enableEnhancedCivicAnswers

      public abstract GenerationConfig.Builder enableEnhancedCivicAnswers(boolean enableEnhancedCivicAnswers)
      Setter for enableEnhancedCivicAnswers.

      enableEnhancedCivicAnswers: Optional. Enables enhanced civic answers. It may not be available for all models. This field is not supported in Vertex AI.

    • clearEnableEnhancedCivicAnswers

      @CanIgnoreReturnValue public GenerationConfig.Builder clearEnableEnhancedCivicAnswers()
      Clears the value of enableEnhancedCivicAnswers field.
    • build

      public abstract GenerationConfig build()