Gemini CLI
Install Gemini CLI and route Gemini-native requests through OneRouter's compatibility prefix.
Managing multiple providers?
Use the CC-Switch guide to switch Gemini CLI providers and keep the OneRouter /gemini endpoint consistent.
Install Gemini CLI
Gemini CLI requires a current Node.js runtime. Verify Node and npm first, then install globally or run it temporarily with npx.
node --version
npm --version
npm install -g @google/gemini-cli
gemini --versionTemporary configuration
At first launch, select the Gemini API key authentication mode. OAuth and Vertex AI use different credentials and endpoints.
export GEMINI_API_KEY="YOUR_ONEROUTER_API_KEY"
export GOOGLE_GEMINI_BASE_URL="https://onerouter.com/gemini"
geminiPersistent configuration
Gemini CLI searches upward for .env and also reads ~/.gemini/.env. Put personal credentials in the user file. The first matching .env wins; files are not merged layer by layer.
GEMINI_API_KEY="YOUR_ONEROUTER_API_KEY"
GOOGLE_GEMINI_BASE_URL="https://onerouter.com/gemini"
GEMINI_MODEL="<MODEL_SLUG>"Verify the connection
Restart Gemini CLI and run a non-interactive smoke test. If a project-level .env exists, verify which file Gemini loaded before troubleshooting the endpoint.
gemini -p "Reply with OK only." --output-format jsonTroubleshooting
| Symptom | How to fix it |
|---|---|
| Google sign-in is requested | Set GEMINI_API_KEY before launch and select API key authentication. |
| Requests still go to Google | Confirm GOOGLE_GEMINI_BASE_URL is present in the current process. |
| 404 | Set the base URL only to /gemini; do not append a model path. |
| Configuration changes between folders | Check whether a project .env shadows ~/.gemini/.env. |
| Certificate error | Install the trusted enterprise CA; do not disable TLS verification. |