1.8 KiB
Model routing
Gemini CLI includes a model routing feature that automatically switches to a fallback model in case of a model failure. This feature is enabled by default and provides resilience when the primary model is unavailable.
How it works
Model routing is managed by the ModelAvailabilityService, which monitors model
health and automatically routes requests to available models based on defined
policies.
-
Model failure: If the currently selected model fails (e.g., due to quota or server errors), the CLI will initiate the fallback process.
-
User consent: Depending on the failure and the model's policy, the CLI may prompt you to switch to a fallback model (by default always prompts you).
Some internal utility calls (such as prompt completion and classification) use a silent fallback chain for
gemini-2.5-flash-liteand will fall back togemini-2.5-flashandgemini-2.5-prowithout prompting or changing the configured model. -
Model switch: If approved, or if the policy allows for silent fallback, the CLI will use an available fallback model for the current turn or the remainder of the session.
Model selection precedence
The model used by Gemini CLI is determined by the following order of precedence:
--modelcommand-line flag: A model specified with the--modelflag when launching the CLI will always be used.GEMINI_MODELenvironment variable: If the--modelflag is not used, the CLI will use the model specified in theGEMINI_MODELenvironment variable.model.nameinsettings.json: If neither of the above are set, the model specified in themodel.nameproperty of yoursettings.jsonfile will be used.- Default model: If none of the above are set, the default model will be
used. The default model is
auto