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
| Item | Value |
|---|---|
| Node.js | ≥ 18 |
| Base URL | https://ai.afp.net (do not add /v1) |
| Recommended model | gemini-3.1-pro; for speed use gemini-3.5-flash / gemini-3.7-flash |
1. Environment and token
node --versionCreate a token under "Token Management" in the console (e.g. gemini-cli) and copy the sk- key.
2. Install
npm install -g @google/gemini-cli
gemini --version3. Configuration
Configuration directory:
- macOS / Linux:
~/.gemini/ - Windows:
C:\Users\{username}\.gemini\
mkdir -p ~/.gemini.env
GOOGLE_GEMINI_BASE_URL=https://ai.afp.net
GEMINI_API_KEY=sk-xxxxxxxx
GEMINI_MODEL=gemini-3.1-proSome 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)
{
"ide": {
"enabled": true
},
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
}
}4. Verify
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
| Symptom | Fix |
|---|---|
| 404 | Check whether the Base URL accidentally includes /v1 or /v1beta |
| Authentication failed | Check that GEMINI_API_KEY is complete and that api-key mode is selected in settings.json |
| Model not found | Check against /v1/models and the token group |
| Permission errors | Configure a user-level npm global directory; avoid messy sudo installs |
| Insufficient quota | Check the balance and token quota in the console |
Back to: Help Center