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 not based on prompt complexity, but is a fallback mechanism. Here's how it works:
-
Model failure: If the currently selected model fails to respond (for example, due to a server error or other issue), the CLI will initiate the fallback process.
-
User consent: The CLI will prompt you to ask if you want to switch to the fallback model. This is handled by the
fallbackModelHandler. -
Fallback activation: If you consent, the CLI will activate the fallback mode by calling
config.setFallbackMode(true). -
Model switch: On the next request, the CLI will use the
DEFAULT_GEMINI_FLASH_MODELas the fallback model. This is handled by theresolveModelfunction inpackages/cli/src/zed-integration/zedIntegration.tswhich checks ifisInFallbackMode()is true.
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