Models Hub
Agent Tools

Gemini CLI

Configure Gemini CLI with your Models Hub API Key and model.

Edit this page

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.

Install the Models Hub CLI:

curl -fsSL https://your-domain/cli/install.sh | sh

Configure only Gemini CLI:

models configure --target gemini --api-key sk-xxx --yes

Specify the default model for Gemini CLI:

models configure --target gemini --api-key sk-xxx --gemini-model gemini-3.1-pro-preview --yes

Configuration 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.com

Manual 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.com

Verification

Reopen your terminal and run:

gemini

Once 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> --yes

Alternatively, manually edit GEMINI_MODEL and model.name in settings.json.

On this page