Use model configuration to control responses  |  Firebase AI Logic

Use model configuration to control responses

GenerationConfig for Gemini models

Click your Gemini API provider to view provider-specific content
and code on this page.
Gemini Developer APIAgent Platform Gemini API

Set a GenerationConfig for the majority of Gemini models, including general-use models, image-generating models ("Nano Banana" models), and text-to-speech (TTS) models.

The configuration is maintained for the lifetime of the GenerativeModel instance. If you want to use a different config, create and use a new instance with a different config.

Code Examples

You can find a description of each parameter in the next section of this page.

LiveGenerationConfig for Gemini Live API models

Click your Gemini API provider to view provider-specific content
and code on this page.
Gemini Developer APIAgent Platform Gemini API

Set a LiveGenerationConfig only when using Gemini Live API models.

The configuration is maintained for the lifetime of the LiveModel instance. If you want to use a different config, create and use a new instance with a different config.

Code Examples

Description of parameters

The following table is a high-level overview of the available parameters. Some parameters are only applicable for certain models.

Parameter Description Limitations Default value
Audio timestamp
audioTimestamp
Enables timestamp understanding for audio-only input files. Boolean

Only applicable when using a GenerativeModel
configuration and the input type is an audio-only file.
false
Max output tokens
maxOutputTokens
Specifies the maximum number of tokens that can be generated in the
response.
--- ---
Stop sequences
stopSequences
Specifies a list of strings that tells the model to stop generating
content if one of the strings is encountered in the response.
Only applicable when using a GenerativeModel
configuration.

Not applicable for
Image models ("Nano Banana") or
TTS models.
---
Specialized configurations
Thinking
thinkingConfig
Controls the "thinking process" for the models when they're
generating a response.

- Control the amount of thinking that the model can do using a
thinking level (Gemini 3.x and later models).

- Control whether to include thought summaries.
Supported values: See the
thinking documentation
Not applicable for TTS models.

Firebase AI Logic does not yet support setting a
thinkingConfig for Live API models.
Depends on the model
Response modalities
responseModalities
Specifies the type of output (like text, audio, or images). Only applicable (and required) when using
Gemini Image models ("Nano Banana" models), TTS models, and
Live API models.
---
Image characteristics
imageConfig
Specifies the aspect ratio and resolution of generated images. Supported values: See
Configure image generation
Only applicable when using Gemini Image models ("Nano Banana"
models).
1:1 aspect ratio (square)
1024x1024 resolution
Speech (voice)
speechConfig
Specifies the voice used for the audio output. Only applicable when using TTS models and Live API models.
Required for TTS models.
Puck

Temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count are unsupported

Parameter Description Limitations Default value
Candidate count
candidateCount
Specifies the number of response variations to return. For each request,
you're charged for the output tokens of all candidates, but you're only
charged once for the input tokens.
Supported values: 1 - 8 (inclusive)

Only applicable when using generateContent.

Not applicable when using generateContentStream,
Image models ("Nano Banana"),
TTS models, or
Live API models.
1
Frequency penalty
frequencyPenalty
Controls the probability of including tokens that repeatedly appear in
the generated response.

Positive values penalize tokens that repeatedly appear in the
generated content, decreasing the probability of repeating content.
Not applicable for
Image models ("Nano Banana") or
TTS models.
---
Presence penalty
presencePenalty
Controls the probability of including tokens that already appear in
the generated response.

Positive values penalize tokens that already appear in the generated
content, increasing the probability of generating more diverse
content.
Not applicable for
Image models ("Nano Banana") or
TTS models.
---
Temperature
temperature
Controls the degree of randomness in the response.
Lower temperatures result in more deterministic responses, and higher
temperatures result in more diverse or creative responses.
--- Depends on the model
Top-K
topK
Limits the number of highest probability words used in the
generated content.
A top-K value of 1 means the next selected token should be
the most probable among all tokens in the model's vocabulary,
while a top-K value of n means that the next token should
be selected from among the n most probable tokens
(all based on the temperature that's set).
--- Depends on the model
Top-P
topP
Controls diversity of generated content.
Tokens are selected from the most probable (see top-K above) to least
probable until the sum of their probabilities equals the top-P value.
--- Depends on the model

Other options to control content generation