Class GenerateContentConfig.Builder
-
- All Implemented Interfaces:
public abstract class GenerateContentConfig.BuilderBuilder for GenerateContentConfig.
-
-
Constructor Summary
Constructors Constructor Description GenerateContentConfig.Builder()
-
Method Summary
-
-
Method Detail
-
httpOptions
abstract GenerateContentConfig.Builder httpOptions(HttpOptions httpOptions)
Setter for httpOptions.
httpOptions: Used to override HTTP request options.
-
httpOptions
@CanIgnoreReturnValue() GenerateContentConfig.Builder httpOptions(HttpOptions.Builder httpOptionsBuilder)
Setter for httpOptions builder.
httpOptions: Used to override HTTP request options.
-
clearHttpOptions
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearHttpOptions()
Clears the value of httpOptions field.
-
shouldReturnHttpResponse
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() GenerateContentConfig.Builder clearShouldReturnHttpResponse()
Clears the value of shouldReturnHttpResponse field.
-
systemInstruction
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() 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() GenerateContentConfig.Builder clearSystemInstruction()
Clears the value of systemInstruction field.
-
temperature
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() GenerateContentConfig.Builder clearTemperature()
Clears the value of temperature field.
-
topP
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() GenerateContentConfig.Builder clearTopP()
Clears the value of topP field.
-
topK
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() GenerateContentConfig.Builder clearTopK()
Clears the value of topK field.
-
candidateCount
abstract GenerateContentConfig.Builder candidateCount(Integer candidateCount)
Setter for candidateCount.
candidateCount: Number of response variations to return.
-
clearCandidateCount
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearCandidateCount()
Clears the value of candidateCount field.
-
maxOutputTokens
abstract GenerateContentConfig.Builder maxOutputTokens(Integer maxOutputTokens)
Setter for maxOutputTokens.
maxOutputTokens: Maximum number of tokens that can be generated in the response.
-
clearMaxOutputTokens
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearMaxOutputTokens()
Clears the value of maxOutputTokens field.
-
stopSequences
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() GenerateContentConfig.Builder stopSequences(Array<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() GenerateContentConfig.Builder clearStopSequences()
Clears the value of stopSequences field.
-
responseLogprobs
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() GenerateContentConfig.Builder clearResponseLogprobs()
Clears the value of responseLogprobs field.
-
logprobs
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() GenerateContentConfig.Builder clearLogprobs()
Clears the value of logprobs field.
-
presencePenalty
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() GenerateContentConfig.Builder clearPresencePenalty()
Clears the value of presencePenalty field.
-
frequencyPenalty
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() GenerateContentConfig.Builder clearFrequencyPenalty()
Clears the value of frequencyPenalty field.
-
seed
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() GenerateContentConfig.Builder clearSeed()
Clears the value of seed field.
-
responseMimeType
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.
-
clearResponseMimeType
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearResponseMimeType()
Clears the value of responseMimeType field.
-
responseSchema
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.
If `response_schema` doesn't process your schema correctly, try using `response_json_schema` instead.
-
responseSchema
@CanIgnoreReturnValue() 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.
If `response_schema` doesn't process your schema correctly, try using `response_json_schema` instead.
-
clearResponseSchema
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearResponseSchema()
Clears the value of responseSchema field.
-
responseJsonSchema
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() GenerateContentConfig.Builder clearResponseJsonSchema()
Clears the value of responseJsonSchema field.
-
routingConfig
abstract GenerateContentConfig.Builder routingConfig(GenerationConfigRoutingConfig routingConfig)
Setter for routingConfig.
routingConfig: Configuration for model router requests.
-
routingConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder routingConfig(GenerationConfigRoutingConfig.Builder routingConfigBuilder)
Setter for routingConfig builder.
routingConfig: Configuration for model router requests.
-
clearRoutingConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearRoutingConfig()
Clears the value of routingConfig field.
-
modelSelectionConfig
abstract GenerateContentConfig.Builder modelSelectionConfig(ModelSelectionConfig modelSelectionConfig)
Setter for modelSelectionConfig.
modelSelectionConfig: Configuration for model selection.
-
modelSelectionConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder modelSelectionConfig(ModelSelectionConfig.Builder modelSelectionConfigBuilder)
Setter for modelSelectionConfig builder.
modelSelectionConfig: Configuration for model selection.
-
clearModelSelectionConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearModelSelectionConfig()
Clears the value of modelSelectionConfig field.
-
safetySettings
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() GenerateContentConfig.Builder safetySettings(Array<SafetySetting> safetySettings)
Setter for safetySettings.
safetySettings: Safety settings in the request to block unsafe content in the response.
-
safetySettings
@CanIgnoreReturnValue() GenerateContentConfig.Builder safetySettings(Array<SafetySetting.Builder> safetySettingsBuilders)
Setter for safetySettings builder.
safetySettings: Safety settings in the request to block unsafe content in the response.
-
clearSafetySettings
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearSafetySettings()
Clears the value of safetySettings field.
-
tools
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() GenerateContentConfig.Builder tools(Array<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() GenerateContentConfig.Builder tools(Array<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() GenerateContentConfig.Builder clearTools()
Clears the value of tools field.
-
toolConfig
abstract GenerateContentConfig.Builder toolConfig(ToolConfig toolConfig)
Setter for toolConfig.
toolConfig: Associates model output to a specific function call.
-
toolConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder toolConfig(ToolConfig.Builder toolConfigBuilder)
Setter for toolConfig builder.
toolConfig: Associates model output to a specific function call.
-
clearToolConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearToolConfig()
Clears the value of toolConfig field.
-
labels
abstract GenerateContentConfig.Builder labels(Map<String, String> labels)
Setter for labels.
labels: Labels with user-defined metadata to break down billed charges.
-
clearLabels
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearLabels()
Clears the value of labels field.
-
cachedContent
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() GenerateContentConfig.Builder clearCachedContent()
Clears the value of cachedContent field.
-
responseModalities
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() GenerateContentConfig.Builder responseModalities(Array<String> responseModalities)
Setter for responseModalities.
responseModalities: The requested modalities of the response. Represents the set of modalities that the model can return.
-
clearResponseModalities
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearResponseModalities()
Clears the value of responseModalities field.
-
mediaResolution
abstract GenerateContentConfig.Builder mediaResolution(MediaResolution mediaResolution)
Setter for mediaResolution.
mediaResolution: If specified, the media resolution specified will be used.
-
clearMediaResolution
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearMediaResolution()
Clears the value of mediaResolution field.
-
mediaResolution
@CanIgnoreReturnValue() 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() GenerateContentConfig.Builder mediaResolution(String mediaResolution)
Setter for mediaResolution given a string.
mediaResolution: If specified, the media resolution specified will be used.
-
speechConfig
abstract GenerateContentConfig.Builder speechConfig(SpeechConfig speechConfig)
Setter for speechConfig.
speechConfig: The speech generation configuration.
-
speechConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder speechConfig(SpeechConfig.Builder speechConfigBuilder)
Setter for speechConfig builder.
speechConfig: The speech generation configuration.
-
clearSpeechConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearSpeechConfig()
Clears the value of speechConfig field.
-
audioTimestamp
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() GenerateContentConfig.Builder clearAudioTimestamp()
Clears the value of audioTimestamp field.
-
automaticFunctionCalling
abstract GenerateContentConfig.Builder automaticFunctionCalling(AutomaticFunctionCallingConfig automaticFunctionCalling)
Setter for automaticFunctionCalling.
automaticFunctionCalling: The configuration for automatic function calling.
-
automaticFunctionCalling
@CanIgnoreReturnValue() GenerateContentConfig.Builder automaticFunctionCalling(AutomaticFunctionCallingConfig.Builder automaticFunctionCallingBuilder)
Setter for automaticFunctionCalling builder.
automaticFunctionCalling: The configuration for automatic function calling.
-
clearAutomaticFunctionCalling
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearAutomaticFunctionCalling()
Clears the value of automaticFunctionCalling field.
-
thinkingConfig
abstract GenerateContentConfig.Builder thinkingConfig(ThinkingConfig thinkingConfig)
Setter for thinkingConfig.
thinkingConfig: The thinking features configuration.
-
thinkingConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder thinkingConfig(ThinkingConfig.Builder thinkingConfigBuilder)
Setter for thinkingConfig builder.
thinkingConfig: The thinking features configuration.
-
clearThinkingConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearThinkingConfig()
Clears the value of thinkingConfig field.
-
imageConfig
abstract GenerateContentConfig.Builder imageConfig(ImageConfig imageConfig)
Setter for imageConfig.
imageConfig: The image generation configuration.
-
imageConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder imageConfig(ImageConfig.Builder imageConfigBuilder)
Setter for imageConfig builder.
imageConfig: The image generation configuration.
-
clearImageConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearImageConfig()
Clears the value of imageConfig field.
-
enableEnhancedCivicAnswers
abstract GenerateContentConfig.Builder enableEnhancedCivicAnswers(boolean enableEnhancedCivicAnswers)
Setter for enableEnhancedCivicAnswers.
enableEnhancedCivicAnswers: Enables enhanced civic answers. It may not be available for all models. This field is not supported in Gemini Enterprise Agent Platform.
-
clearEnableEnhancedCivicAnswers
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearEnableEnhancedCivicAnswers()
Clears the value of enableEnhancedCivicAnswers field.
-
modelArmorConfig
abstract GenerateContentConfig.Builder modelArmorConfig(ModelArmorConfig modelArmorConfig)
Setter for modelArmorConfig.
modelArmorConfig: Settings for prompt and response sanitization using the Model Armor service. If supplied, safety_settings must not be supplied.
-
modelArmorConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder modelArmorConfig(ModelArmorConfig.Builder modelArmorConfigBuilder)
Setter for modelArmorConfig builder.
modelArmorConfig: Settings for prompt and response sanitization using the Model Armor service. If supplied, safety_settings must not be supplied.
-
clearModelArmorConfig
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearModelArmorConfig()
Clears the value of modelArmorConfig field.
-
serviceTier
abstract GenerateContentConfig.Builder serviceTier(ServiceTier serviceTier)
Setter for serviceTier.
serviceTier: The service tier to use for the request. For example, ServiceTier.FLEX.
-
clearServiceTier
@CanIgnoreReturnValue() GenerateContentConfig.Builder clearServiceTier()
Clears the value of serviceTier field.
-
serviceTier
@CanIgnoreReturnValue() GenerateContentConfig.Builder serviceTier(ServiceTier.Known knownType)
Setter for serviceTier given a known enum.
serviceTier: The service tier to use for the request. For example, ServiceTier.FLEX.
-
serviceTier
@CanIgnoreReturnValue() GenerateContentConfig.Builder serviceTier(String serviceTier)
Setter for serviceTier given a string.
serviceTier: The service tier to use for the request. For example, ServiceTier.FLEX.
-
build
abstract GenerateContentConfig build()
-
-
-
-