GenerationConfig.Builder

class GenerationConfig.Builder


Builder for creating a GenerationConfig.

Mainly intended for Java interop. Kotlin consumers should use generationConfig for a more idiomatic experience.

See also
generationConfig

Summary

Public constructors

Public functions

GenerationConfig

Create a new GenerationConfig with the attached arguments.

GenerationConfig.Builder
setCandidateCount(candidateCount: Int?)

This function is deprecated. `candidateCount` is unsupported in Gemini 3.x and later models

GenerationConfig.Builder
setFrequencyPenalty(frequencyPenalty: Float?)

This function is deprecated. `frequencyPenalty` is unsupported in Gemini 3.x and later models

GenerationConfig.Builder
setImageConfig(imageConfig: ImageConfig?)
GenerationConfig.Builder
setMaxOutputTokens(maxOutputTokens: Int?)
GenerationConfig.Builder
setPresencePenalty(presencePenalty: Float?)

This function is deprecated. `presencePenalty` is unsupported in Gemini 3.x and later models

GenerationConfig.Builder
setResponseMimeType(responseMimeType: String?)
GenerationConfig.Builder
GenerationConfig.Builder
setResponseSchema(responseSchema: Schema?)
GenerationConfig.Builder
setResponseSchemaJson(responseSchemaJson: JsonSchema<*>?)
GenerationConfig.Builder
setSpeechConfig(speechConfig: SpeechConfig?)
GenerationConfig.Builder
setStopSequences(stopSequences: List<String>?)
GenerationConfig.Builder
setTemperature(temperature: Float?)

This function is deprecated. `temperature` is unsupported in Gemini 3.x and later models

GenerationConfig.Builder
GenerationConfig.Builder
setTopK(topK: Int?)

This function is deprecated. `topK` is unsupported in Gemini 3.x and later models

GenerationConfig.Builder
setTopP(topP: Float?)

This function is deprecated. `topP` is unsupported in Gemini 3.x and later models

Public constructors

Builder

Builder()

Public functions

build

fun build(): GenerationConfig

Create a new GenerationConfig with the attached arguments.

setCandidateCount

fun setCandidateCount(candidateCount: Int?): GenerationConfig.Builder

setFrequencyPenalty

fun setFrequencyPenalty(frequencyPenalty: Float?): GenerationConfig.Builder

setImageConfig

fun setImageConfig(imageConfig: ImageConfig?): GenerationConfig.Builder

setMaxOutputTokens

fun setMaxOutputTokens(maxOutputTokens: Int?): GenerationConfig.Builder

setPresencePenalty

fun setPresencePenalty(presencePenalty: Float?): GenerationConfig.Builder

setResponseMimeType

fun setResponseMimeType(responseMimeType: String?): GenerationConfig.Builder

setResponseModalities

fun setResponseModalities(responseModalities: List<ResponseModality>?): GenerationConfig.Builder

setResponseSchema

fun setResponseSchema(responseSchema: Schema?): GenerationConfig.Builder

setResponseSchemaJson

fun setResponseSchemaJson(responseSchemaJson: JsonSchema<*>?): GenerationConfig.Builder

setSpeechConfig

fun setSpeechConfig(speechConfig: SpeechConfig?): GenerationConfig.Builder

setStopSequences

fun setStopSequences(stopSequences: List<String>?): GenerationConfig.Builder

setTemperature

fun setTemperature(temperature: Float?): GenerationConfig.Builder

setThinkingConfig

fun setThinkingConfig(thinkingConfig: ThinkingConfig?): GenerationConfig.Builder

setTopK

fun setTopK(topK: Int?): GenerationConfig.Builder

setTopP

fun setTopP(topP: Float?): GenerationConfig.Builder

Public properties

candidateCount

var candidateCount: Int?

Deprecated. See GenerationConfig.candidateCount.

frequencyPenalty

var frequencyPenalty: Float?

Deprecated. See GenerationConfig.frequencyPenalty

presencePenalty

var presencePenalty: Float?

Deprecated. See GenerationConfig.presencePenalty

temperature

var temperature: Float?

Deprecated. See GenerationConfig.temperature.

thinkingConfig

var thinkingConfig: ThinkingConfig?

topK

var topK: Int?

Deprecated. See GenerationConfig.topK.

topP

var topP: Float?

Deprecated. See GenerationConfig.topP.