Gemini CLI
Configure Gemini CLI with your Models Hub API Key and model.
Gemini CLI can connect to Models Hub via an API Key and environment variables. We recommend using the Models Hub CLI for one-click configuration; if you need to check or adjust the configuration manually, refer to this page.
Recommended: Use Models Hub CLI
Install the Models Hub CLI:
curl -fsSL https://your-domain/cli/install.sh | shConfigure only Gemini CLI:
models configure --target gemini --api-key sk-xxx --yesSpecify the default model for Gemini CLI:
models configure --target gemini --api-key sk-xxx --gemini-model gemini-3.1-pro-preview --yesConfiguration written
The Models Hub CLI writes to:
~/.gemini/settings.json~/.gemini/.env
settings.json enables API Key authentication, and .env is populated with:
GEMINI_API_KEY=sk-xxx
GEMINI_MODEL=gemini-3.1-pro-preview
GOOGLE_GEMINI_BASE_URL=https://modelsok.comManual configuration
If you prefer not to use the Models Hub CLI, you can manually create or edit ~/.gemini/settings.json:
{
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
},
"model": {
"name": "gemini-3.1-pro-preview"
}
}Then create or edit ~/.gemini/.env:
GEMINI_API_KEY=sk-xxx
GEMINI_MODEL=gemini-3.1-pro-preview
GOOGLE_GEMINI_BASE_URL=https://modelsok.comVerification
Reopen your terminal and run:
geminiOnce inside Gemini CLI, send a test message. If the model responds normally, you have successfully connected to Models Hub.
FAQ
Changes don't take effect after editing the configuration
Reopen your terminal and confirm that Gemini CLI is reading ~/.gemini/settings.json and ~/.gemini/.env in the current user's home directory.
Switching models
You can re-run:
models configure --target gemini --api-key sk-xxx --gemini-model <model-id> --yesAlternatively, manually edit GEMINI_MODEL and model.name in settings.json.