| The examples on this page assume that you've completed the Get started: Access the Gemini API through Apple's Foundation Models framework. |
In each request to a model, you can send along some configuration settings to control how the model generates a response. Each Gemini model offers different configuration options.
Depending on the setting, the configuration is maintained for the lifetime of
the geminiLanguageModel or the LanguageModelSession. If you want to
use a different configuration, create a new model or session with that config.
The page describes the following configuration options:
Specify system instructions
System instructions are like a "preamble" that you add before the model gets exposed to any further instructions from the end user. It lets you steer the behavior of the model based on your specific needs and use cases.
Specify system instructions on the LanguageModelSession:
// ...
// Make sure you initialize your chosen Gemini API backend service
let model = FirebaseAI.firebaseAI().geminiLanguageModel(name: "GEMINI_MODEL_NAME")
// Specify the system instructions as part of creating the session
let session = LanguageModelSession(
model: model,
instructions: "You are a cat. Your name is Neko."
)
// ...
Configure thinking (aka "reasoning")
You can configure the amount of thinking (also called reasoning) that a Gemini model can do to generate its response. For details, best practices, and use cases for thinking, see the general Thinking guide.
Instead of thinking level, Apple uses reasoning level. You set the
reasoningLevel on the LanguageModelSession:
// ...
// Make sure you initialize your chosen Gemini API backend service
let model = FirebaseAI.firebaseAI().geminiLanguageModel(name: "GEMINI_MODEL_NAME")
// Specify the reasoning level as part of creating the session
// Possible reasoningLevels: .light, .moderate, .deep, .custom("minimal")
let session = LanguageModelSession(
model: model,
contextOptions: ContextOptions(reasoningLevel: .REASONING_LEVEL))
// ...
Supported thinking level values
Note the following:
- Gemini 3.x models always use thinking; you cannot disable or turn off thinking for these models.
- Gemini 3.x models always use dynamic thinking – the model decides when and how much it thinks up to the configured amount.
The following table lists the thinking levels (reasoningLevel) that you can
set for each Gemini model. Note that if you use a Gemini value
(MINIMAL, LOW, MEDIUM, HIGH), it will be automatically mapped to the
Apple version of that value.
Apple: .custom("minimal")Gemini: MINIMAL
|
Apple: .lightGemini: LOW
|
Apple: .moderateGemini: MEDIUM
|
Apple: .deepGemini: HIGH
|
|
|---|---|---|---|---|
|
Model uses as few tokens as possible; close to no thinking Low-complexity tasks |
Model uses fewer tokens; minimizes latency & cost Simple tasks and high-throughput tasks |
Model uses a balanced approach Moderate complexity tasks |
Model uses tokens up to its maximum level Complex prompts that require deep reasoning |
|
gemini-3.1-pro-preview |
(default) | |||
gemini-3.5-flash |
(default) | |||
gemini-3.1-flash-lite |
(default) | |||
gemini-3-pro-image-preview ("Nano Banana Pro") |
(default) | |||
gemini-3.1-flash-image-preview ("Nano Banana 2") |
(default) |
Configure image output
General configuration
Give feedback about accessing the Gemini API through Apple's Foundation Models framework