Gemini CLI
Gemini CLI is Google's command-line AI assistant. It uses the Gemini API.
Preparation
- Install Gemini CLI:
npm install -g @google/gemini-cli - In the console, create a token in the
geminigroup.
Configuration
Set two environment variables:
bash
export GOOGLE_GEMINI_BASE_URL="https://api.codingrouter.ai"
export GEMINI_API_KEY="sk-your-token"
geminipowershell
$env:GOOGLE_GEMINI_BASE_URL = "https://api.codingrouter.ai"
$env:GEMINI_API_KEY = "sk-your-token"
geminiWhen you choose the authentication method on first launch, select Use Gemini API Key.
You can also write it directly into the config file ~/.gemini/settings.json to skip this step:
json
{
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
}
}Non-interactive runs (gemini -p, scripts, CI) require this setting, otherwise you get Invalid auth method selected.
Choosing a model
bash
gemini -m gemini-3.7-flashVerify
bash
gemini -m gemini-3.5-flash -p "Reply with exactly: CODINGROUTER OK"When running non-interactively in a directory you have not trusted, Gemini CLI asks you to trust the directory first. Add --skip-trust or set GEMINI_CLI_TRUST_WORKSPACE=true.
Troubleshooting
| Symptom | What to do |
|---|---|
Invalid auth method selected | Set selectedType in settings.json as described above |
not running in a trusted directory | Trust the directory in interactive mode, or add --skip-trust when non-interactive |
| Returns 403 or 503 | The token's group is not gemini, or the model name is wrong |
