Gemini CLI
Use Gemini CLI with gateway API-key authentication and the native v1beta API.
Install and prepare
- Install Node.js 20 or later, then the official Gemini CLI npm package below. Check
gemini --version. - In routerra.ai API Keys, create a key with access to a native Gemini model from Models. This connection uses Gemini
generateContent/streamGenerateContent, not OpenAI Chat Completions.
npm install -g @google/gemini-cli
gemini --version
Configure native Gemini routing
- Set the three variables below in the terminal launching Gemini CLI. The SDK appends
/v1beta/models/..., soGOOGLE_GEMINI_BASE_URLmust behttps://routerra.aiwithout/v1or/v1beta. Replace the key and model placeholders. - When prompted, choose Use Gemini API key; newer builds may detect gateway authentication automatically. An existing Google-login or Vertex session can bypass this route: use
/authto change it. For persistence, save the variables asNAME=valuelines in~/.gemini/.env, then restart Gemini CLI. Do not commit that file.
export GEMINI_API_KEY="YOUR_API_KEY"
export GOOGLE_GEMINI_BASE_URL="https://routerra.ai"
export GOOGLE_GENAI_API_VERSION="v1beta"
gemini --model YOUR_GEMINI_MODEL_ID
For Windows PowerShell:
$env:GEMINI_API_KEY = "YOUR_API_KEY"
$env:GOOGLE_GEMINI_BASE_URL = "https://routerra.ai"
$env:GOOGLE_GENAI_API_VERSION = "v1beta"
gemini --model YOUR_GEMINI_MODEL_ID
Check the connection
Test a short prompt with the explicit --model ID. A Google sign-in page indicates the wrong authentication mode. A request to /v1/v1beta or /v1beta/v1beta means the base URL contains an extra path. If the selected model is rejected, check its native Gemini availability instead of substituting an OpenAI model ID. Remove conflicting GOOGLE_GENAI_USE_VERTEXAI or GOOGLE_GENAI_USE_GCA settings, restart, and confirm usage in routerra.ai.