Skip to main content
GemAI supports multiple Google Gemini models, each with different capabilities and performance characteristics. This guide covers available models and how to configure them.

Available models

GemAI provides three Gemini model options through the AIModel enum:
UserConfig.kt
enum class AIModel(val modelName: String, val number: Int) {
    GEMINI_2_0_FLASH_EXP("gemini-2.0-flash-exp", 0),
    GEMINI_1_5_FLASH("gemini-1.5-flash", 1),
    GEMINI_1_5_PRO("gemini-1.5-pro-latest", 2);

    companion object {
        fun fromNum(id: Int?): AIModel {
            return when (id) {
                0 -> GEMINI_2_0_FLASH_EXP
                1 -> GEMINI_1_5_FLASH
                2 -> GEMINI_1_5_PRO
                else -> GEMINI_1_5_FLASH
            }
        }
    }
}

Gemini 2.0 Flash (Experimental)

GEMINI_2_0_FLASH_EXP
AIModel
Model name: gemini-2.0-flash-expThe latest experimental version with cutting-edge features. Best for testing new capabilities and getting early access to improvements.
Experimental models may have breaking changes or unexpected behavior. Use with caution in production environments.

Gemini 1.5 Flash

GEMINI_1_5_FLASH
AIModel
default:true
Model name: gemini-1.5-flashThe default model optimized for speed and efficiency. Ideal for most chat applications with fast response times and lower costs.
This is the default model used by GemAI. It provides the best balance between performance and quality for everyday conversations.

Gemini 1.5 Pro

GEMINI_1_5_PRO
AIModel
Model name: gemini-1.5-pro-latestThe most capable model with enhanced reasoning and understanding. Best for complex tasks requiring deeper analysis and more nuanced responses.

Selecting a model

You can configure the model using the ModelBuilder.setModel() method:
ModelBuilder.kt
val model = ModelBuilder.Builder()
    .setApiKey("your-api-key")
    .setModel(AIModel.GEMINI_1_5_PRO.modelName)
    .build()
The setModel() method accepts a string parameter:
ModelBuilder.kt
fun setModel(modelName: String) = apply { 
    this.modelName = modelName 
}

Persisting model selection

GemAI persists your model selection in DataStore so it remains active across app sessions:
DatastoreRepositoryImpl.kt
override suspend fun saveModel(model: AIModel) {
    dataStore.updateData { config ->
        config.toBuilder()
            .setModel(com.sarath.gem.AIModel.forNumber(model.number))
            .build()
    }
}
To retrieve the saved model:
DatastoreRepositoryImpl.kt
override suspend fun getModel(): AIModel {
    return AIModel.fromNum(dataStore.data.firstOrNull()?.model?.number)
}

Generation configuration

Beyond selecting a model, you can fine-tune its behavior using generation parameters. The ModelBuilder provides a setConfig() method:
ModelBuilder.kt
fun setConfig(configure: GenerationConfig.Builder.() -> Unit) = apply {
    generationConfig = generationConfig(configure)
}

Default configuration

GemAI uses these default generation settings:
ModelBuilder.kt
private var generationConfig = generationConfig {
    temperature = 0.6f
    topP = 0.8f
    topK = 30
    stopSequences = listOf("End of response", "STOP")
}

Configuration parameters

temperature
Float
default:"0.6"
Controls randomness in responses. Lower values (0.0-0.5) make output more focused and deterministic. Higher values (0.5-2.0) increase creativity and randomness.
topP
Float
default:"0.8"
Controls diversity via nucleus sampling. The model considers tokens with cumulative probability up to this value. Range: 0.0 to 1.0.
topK
Int
default:"30"
Limits the number of highest probability tokens to consider. Lower values make responses more focused, higher values add variety.
stopSequences
List<String>
default:"[\"End of response\", \"STOP\"]"
Strings that signal the model to stop generating. Useful for controlling response length and format.

Custom configuration example

Here’s how to customize generation settings for different use cases:
val creativeModel = ModelBuilder.Builder()
    .setApiKey(apiKey)
    .setModel(AIModel.GEMINI_1_5_PRO.modelName)
    .setConfig {
        temperature = 1.2f
        topP = 0.95f
        topK = 50
    }
    .build()

Building the model

After configuration, call build() to create the GenerativeModel instance:
ModelBuilder.kt
fun build(): GenerativeModel {
    require(apiKey.isNotBlank()) { "API key must not be blank" }
    require(modelName.isNotBlank()) { "Model name must not be blank" }
    return GenerativeModel(
        apiKey = apiKey,
        modelName = modelName,
        generationConfig = generationConfig,
        safetySettings = safetySettings,
        systemInstruction = getSystemInstruction(),
    )
}
The build() method validates that both apiKey and modelName are not blank before creating the model instance.

Choosing the right model

Use this guide to select the appropriate model:
Use caseRecommended modelWhy
Quick chat responsesGemini 1.5 FlashFastest response times, lowest cost
Complex reasoningGemini 1.5 ProBetter at multi-step logic and analysis
Testing new featuresGemini 2.0 Flash ExpAccess to latest capabilities
Production appsGemini 1.5 Flash or ProStable, well-tested models

Build docs developers (and LLMs) love