GenerationConfigKt

Kotlin |Java

public final class GenerationConfigKt 


Summary

Public methods

static final @NonNull GenerationConfig

Helper method to construct a GenerationConfig in a DSL-like manner.

Public methods

generationConfig

public static final @NonNull GenerationConfig generationConfig(
@ExtensionFunctionType @NonNull Function1<@NonNull GenerationConfig.Builder, Unit> init
)

Helper method to construct a GenerationConfig in a DSL-like manner.

Example usage:

// Default generation config - uses ModelConfig.DEFAULT and a default background thread pool.
val config1 = generationConfig {}

// Customized model spec
val config2 = generationConfig {
workerExecutor = myExecutor
modelConfig = modelConfig {
releaseStage = ModelReleaseStage.PREVIEW
preference = ModelPreference.FAST
}
}

// Using prebuilt default ModelConfig with a custom executor
val config3 = generationConfig {
workerExecutor = myExecutor
modelConfig = ModelConfig.DEFAULT
}

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026年04月02日 UTC.