Skip to content

Gemini CLI Configuration Guide ​

Last updated: October 17, 2026 (Asia/Shanghai)

Related: Help Center · LLM API · Image Generation

Applies to: using Google Gemini CLI in the terminal to call Gemini-family models through tokenexplore.

Key settings

ItemValue
Node.js≥ 18
Base URLhttps://ai.afp.net (do not add /v1)
Recommended modelgemini-3.1-pro; for speed use gemini-3.5-flash / gemini-3.7-flash

1. Environment and token ​

bash
node --version

Create a token under "Token Management" in the console (e.g. gemini-cli) and copy the sk- key.


2. Install ​

bash
npm install -g @google/gemini-cli
gemini --version

3. Configuration ​

Configuration directory:

  • macOS / Linux: ~/.gemini/
  • Windows: C:\Users\{username}\.gemini\
bash
mkdir -p ~/.gemini

.env ​

env
GOOGLE_GEMINI_BASE_URL=https://ai.afp.net
GEMINI_API_KEY=sk-xxxxxxxx
GEMINI_MODEL=gemini-3.1-pro

Some environments also read ~/.env in the project or user directory; behavior depends on the current Gemini CLI version. Make sure ~/.gemini/.env is correct first.

settings.json (optional) ​

json
{
  "ide": {
    "enabled": true
  },
  "security": {
    "auth": {
      "selectedType": "gemini-api-key"
    }
  }
}

4. Verify ​

bash
gemini
# or non-interactive (the subcommand depends on the version)
gemini -p "introduce tokenexplore in three sentences"

Model switching examples: gemini-3.5-flash, gemini-3.1-pro-preview, gemini-2.5-pro. Image-generation models (gemini-3-pro-image, etc.) are better used through the Image Generation API or an SDK; whether the CLI exposes image generation depends on the version.


5. Troubleshooting ​

SymptomFix
404Check whether the Base URL accidentally includes /v1 or /v1beta
Authentication failedCheck that GEMINI_API_KEY is complete and that api-key mode is selected in settings.json
Model not foundCheck against /v1/models and the token group
Permission errorsConfigure a user-level npm global directory; avoid messy sudo installs
Insufficient quotaCheck the balance and token quota in the console

Back to: Help Center