Class GenerateContentConfig.Builder

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

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

    • Builder

      public Builder()
  • Method Details

    • httpOptions

      public abstract GenerateContentConfig.Builder httpOptions(HttpOptions httpOptions)
      Setter for httpOptions.

      httpOptions: Used to override HTTP request options.

    • httpOptions

      @CanIgnoreReturnValue public GenerateContentConfig.Builder httpOptions(HttpOptions.Builder httpOptionsBuilder)
      Setter for httpOptions builder.

      httpOptions: Used to override HTTP request options.

    • clearHttpOptions

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearHttpOptions()
      Clears the value of httpOptions field.
    • shouldReturnHttpResponse

      public abstract GenerateContentConfig.Builder shouldReturnHttpResponse(boolean shouldReturnHttpResponse)
      Setter for shouldReturnHttpResponse.

      shouldReturnHttpResponse: If true, the raw HTTP response will be returned in the 'sdk_http_response' field.

    • clearShouldReturnHttpResponse

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearShouldReturnHttpResponse()
      Clears the value of shouldReturnHttpResponse field.
    • systemInstruction

      public abstract GenerateContentConfig.Builder systemInstruction(Content systemInstruction)
      Setter for systemInstruction.

      systemInstruction: Instructions for the model to steer it toward better performance. For example, "Answer as concisely as possible" or "Don't use technical terms in your response".

    • systemInstruction

      @CanIgnoreReturnValue public GenerateContentConfig.Builder systemInstruction(Content.Builder systemInstructionBuilder)
      Setter for systemInstruction builder.

      systemInstruction: Instructions for the model to steer it toward better performance. For example, "Answer as concisely as possible" or "Don't use technical terms in your response".

    • clearSystemInstruction

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearSystemInstruction()
      Clears the value of systemInstruction field.
    • temperature

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

      temperature: Value that controls the degree of randomness in token selection. Lower temperatures are good for prompts that require a less open-ended or creative response, while higher temperatures can lead to more diverse or creative results.

    • clearTemperature

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearTemperature()
      Clears the value of temperature field.
    • topP

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

      topP: Tokens are selected from the most to least probable until the sum of their probabilities equals this value. Use a lower value for less random responses and a higher value for more random responses.

    • clearTopP

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearTopP()
      Clears the value of topP field.
    • topK

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

      topK: For each token selection step, the ``top_k`` tokens with the highest probabilities are sampled. Then tokens are further filtered based on ``top_p`` with the final token selected using temperature sampling. Use a lower number for less random responses and a higher number for more random responses.

    • clearTopK

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearTopK()
      Clears the value of topK field.
    • candidateCount

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

      candidateCount: Number of response variations to return.

    • clearCandidateCount

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearCandidateCount()
      Clears the value of candidateCount field.
    • maxOutputTokens

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

      maxOutputTokens: Maximum number of tokens that can be generated in the response.

    • clearMaxOutputTokens

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearMaxOutputTokens()
      Clears the value of maxOutputTokens field.
    • stopSequences

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

      stopSequences: List of strings that tells the model to stop generating text if one of the strings is encountered in the response.

    • stopSequences

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

      stopSequences: List of strings that tells the model to stop generating text if one of the strings is encountered in the response.

    • clearStopSequences

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearStopSequences()
      Clears the value of stopSequences field.
    • responseLogprobs

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

      responseLogprobs: Whether to return the log probabilities of the tokens that were chosen by the model at each step.

    • clearResponseLogprobs

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearResponseLogprobs()
      Clears the value of responseLogprobs field.
    • logprobs

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

      logprobs: Number of top candidate tokens to return the log probabilities for at each generation step.

    • clearLogprobs

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearLogprobs()
      Clears the value of logprobs field.
    • presencePenalty

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

      presencePenalty: Positive values penalize tokens that already appear in the generated text, increasing the probability of generating more diverse content.

    • clearPresencePenalty

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearPresencePenalty()
      Clears the value of presencePenalty field.
    • frequencyPenalty

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

      frequencyPenalty: Positive values penalize tokens that repeatedly appear in the generated text, increasing the probability of generating more diverse content.

    • clearFrequencyPenalty

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearFrequencyPenalty()
      Clears the value of frequencyPenalty field.
    • seed

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

      seed: When ``seed`` is fixed to a specific number, the model makes a best effort to provide the same response for repeated requests. By default, a random number is used.

    • clearSeed

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearSeed()
      Clears the value of seed field.
    • responseMimeType

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

      responseMimeType: 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 GenerateContentConfig.Builder clearResponseMimeType()
      Clears the value of responseMimeType field.
    • responseSchema

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

      responseSchema: 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 GenerateContentConfig.Builder responseSchema(Schema.Builder responseSchemaBuilder)
      Setter for responseSchema builder.

      responseSchema: 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 GenerateContentConfig.Builder clearResponseSchema()
      Clears the value of responseSchema field.
    • responseJsonSchema

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

      responseJsonSchema: Optional. Output schema of the generated response. This is an alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If set, `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than those starting as a `$`, may be set.

    • clearResponseJsonSchema

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearResponseJsonSchema()
      Clears the value of responseJsonSchema field.
    • routingConfig

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

      routingConfig: Configuration for model router requests.

    • routingConfig

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

      routingConfig: Configuration for model router requests.

    • clearRoutingConfig

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearRoutingConfig()
      Clears the value of routingConfig field.
    • modelSelectionConfig

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

      modelSelectionConfig: Configuration for model selection.

    • modelSelectionConfig

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

      modelSelectionConfig: Configuration for model selection.

    • clearModelSelectionConfig

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearModelSelectionConfig()
      Clears the value of modelSelectionConfig field.
    • safetySettings

      public abstract GenerateContentConfig.Builder safetySettings(List<SafetySetting> safetySettings)
      Setter for safetySettings.

      safetySettings: Safety settings in the request to block unsafe content in the response.

    • safetySettings

      @CanIgnoreReturnValue public GenerateContentConfig.Builder safetySettings(SafetySetting... safetySettings)
      Setter for safetySettings.

      safetySettings: Safety settings in the request to block unsafe content in the response.

    • safetySettings

      @CanIgnoreReturnValue public GenerateContentConfig.Builder safetySettings(SafetySetting.Builder... safetySettingsBuilders)
      Setter for safetySettings builder.

      safetySettings: Safety settings in the request to block unsafe content in the response.

    • clearSafetySettings

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearSafetySettings()
      Clears the value of safetySettings field.
    • tools

      public abstract GenerateContentConfig.Builder tools(List<Tool> tools)
      Setter for tools.

      tools: Code that enables the system to interact with external systems to perform an action outside of the knowledge and scope of the model.

    • tools

      @CanIgnoreReturnValue public GenerateContentConfig.Builder tools(Tool... tools)
      Setter for tools.

      tools: Code that enables the system to interact with external systems to perform an action outside of the knowledge and scope of the model.

    • tools

      @CanIgnoreReturnValue public GenerateContentConfig.Builder tools(Tool.Builder... toolsBuilders)
      Setter for tools builder.

      tools: Code that enables the system to interact with external systems to perform an action outside of the knowledge and scope of the model.

    • clearTools

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearTools()
      Clears the value of tools field.
    • toolConfig

      public abstract GenerateContentConfig.Builder toolConfig(ToolConfig toolConfig)
      Setter for toolConfig.

      toolConfig: Associates model output to a specific function call.

    • toolConfig

      @CanIgnoreReturnValue public GenerateContentConfig.Builder toolConfig(ToolConfig.Builder toolConfigBuilder)
      Setter for toolConfig builder.

      toolConfig: Associates model output to a specific function call.

    • clearToolConfig

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearToolConfig()
      Clears the value of toolConfig field.
    • labels

      public abstract GenerateContentConfig.Builder labels(Map<String,String> labels)
      Setter for labels.

      labels: Labels with user-defined metadata to break down billed charges.

    • clearLabels

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearLabels()
      Clears the value of labels field.
    • cachedContent

      public abstract GenerateContentConfig.Builder cachedContent(String cachedContent)
      Setter for cachedContent.

      cachedContent: Resource name of a context cache that can be used in subsequent requests.

    • clearCachedContent

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearCachedContent()
      Clears the value of cachedContent field.
    • responseModalities

      public abstract GenerateContentConfig.Builder responseModalities(List<String> responseModalities)
      Setter for responseModalities.

      responseModalities: The requested modalities of the response. Represents the set of modalities that the model can return.

    • responseModalities

      @CanIgnoreReturnValue public GenerateContentConfig.Builder responseModalities(String... responseModalities)
      Setter for responseModalities.

      responseModalities: The requested modalities of the response. Represents the set of modalities that the model can return.

    • clearResponseModalities

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

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

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

    • clearMediaResolution

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

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

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

    • mediaResolution

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

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

    • speechConfig

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

      speechConfig: The speech generation configuration.

    • speechConfig

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

      speechConfig: The speech generation configuration.

    • clearSpeechConfig

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearSpeechConfig()
      Clears the value of speechConfig field.
    • audioTimestamp

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

      audioTimestamp: If enabled, audio timestamp will be included in the request to the model.

    • clearAudioTimestamp

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearAudioTimestamp()
      Clears the value of audioTimestamp field.
    • automaticFunctionCalling

      public abstract GenerateContentConfig.Builder automaticFunctionCalling(AutomaticFunctionCallingConfig automaticFunctionCalling)
      Setter for automaticFunctionCalling.

      automaticFunctionCalling: The configuration for automatic function calling.

    • automaticFunctionCalling

      @CanIgnoreReturnValue public GenerateContentConfig.Builder automaticFunctionCalling(AutomaticFunctionCallingConfig.Builder automaticFunctionCallingBuilder)
      Setter for automaticFunctionCalling builder.

      automaticFunctionCalling: The configuration for automatic function calling.

    • clearAutomaticFunctionCalling

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearAutomaticFunctionCalling()
      Clears the value of automaticFunctionCalling field.
    • thinkingConfig

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

      thinkingConfig: The thinking features configuration.

    • thinkingConfig

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

      thinkingConfig: The thinking features configuration.

    • clearThinkingConfig

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearThinkingConfig()
      Clears the value of thinkingConfig field.
    • imageConfig

      public abstract GenerateContentConfig.Builder imageConfig(ImageConfig imageConfig)
      Setter for imageConfig.

      imageConfig: The image generation configuration.

    • imageConfig

      @CanIgnoreReturnValue public GenerateContentConfig.Builder imageConfig(ImageConfig.Builder imageConfigBuilder)
      Setter for imageConfig builder.

      imageConfig: The image generation configuration.

    • clearImageConfig

      @CanIgnoreReturnValue public GenerateContentConfig.Builder clearImageConfig()
      Clears the value of imageConfig field.
    • build

      public abstract GenerateContentConfig build()