Skip to content

Gemini CLI ​

Gemini CLI is Google's command-line AI assistant. It uses the Gemini API.

Preparation ​

  1. Install Gemini CLI: npm install -g @google/gemini-cli
  2. In the console, create a token in the gemini group.

Configuration ​

Set two environment variables:

bash
export GOOGLE_GEMINI_BASE_URL="https://api.codingrouter.ai"
export GEMINI_API_KEY="sk-your-token"
gemini
powershell
$env:GOOGLE_GEMINI_BASE_URL = "https://api.codingrouter.ai"
$env:GEMINI_API_KEY = "sk-your-token"
gemini

When 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-flash

Verify ​

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 ​

SymptomWhat to do
Invalid auth method selectedSet selectedType in settings.json as described above
not running in a trusted directoryTrust the directory in interactive mode, or add --skip-trust when non-interactive
Returns 403 or 503The token's group is not gemini, or the model name is wrong