Gemini CLI
Install the official Gemini CLI and configure the UniRoute native Gemini API.
Gemini CLI · pay-as-you-go API
Connect Google Gemini CLI to UniRoute through the native Gemini API. The setup command selects API-key authentication and your default model.
Best for: Developers who use Gemini in a terminal and want one usage record in UniRoute.
Quick setup
Sign in to create a key and fill it in automatically Sign in
UNIROUTE_API_KEY=YOUR_UNIROUTE_API_KEY npx -y uniroute-setup@latest configure gemini --model gemini-3.8-flash$env:UNIROUTE_API_KEY="YOUR_UNIROUTE_API_KEY"; npx -y uniroute-setup@latest configure gemini --model gemini-3.8-flashRequires Node.js 22+ for the setup tool. Add --dry-run to preview the file changes without writing; --home /path/to/test-home uses an isolated home. Existing changed files are backed up and unrelated settings are preserved.
Manual configuration
1. Locate and back up the files
macOS / Linux: ~/.gemini/.env and ~/.gemini/settings.json. Windows: $HOME\.gemini\.env and $HOME\.gemini\settings.json. Back up existing files before merging.
2. Merge the provider settings
GOOGLE_GEMINI_BASE_URL=https://api.uniroute.app
GEMINI_API_KEY=YOUR_UNIROUTE_API_KEY
GEMINI_MODEL=gemini-3.8-flash3. Select API-key authentication
{
"security": {
"auth": { "selectedType": "gemini-api-key" }
}
}Merge the JSON block into settings.json. Keep other settings. The root URL has no /v1 suffix: Gemini CLI adds its native /v1beta route. Select a native Gemini model, rather than an OpenAI-compatible alias.
4. Restart the client
gemini
What these fields do
| Field | Purpose |
|---|---|
| GOOGLE_GEMINI_BASE_URL | The root for native Gemini API requests. |
| GEMINI_API_KEY | Your UniRoute API key. |
| GEMINI_MODEL | The native Gemini model to start with. |
| selectedType | gemini-api-key selects the key-based authentication flow. |
Choose a model
Confirm the connection
Check status with /model to inspect the active model and service.
Send a short test: gemini -p "Reply only: hello"
Open usage logs to review the model, request status and charge. The test is a real, billed API request.
Match its time, model, and actual charge in the usage log. Keep the key in private configuration and out of repositories.
Switch back / restore a backup
Exit Gemini CLI and restore the .env and settings.json backups printed by the tool. To return to Google account authentication, restore the previous selected authentication type and credentials, then reopen the client.
If a file was new and has no backup, remove only the fields added by this setup and preserve settings added later.
Not installed yet?
Install Node.js 22+ for the setup tool, then follow the official Gemini CLI installation guide:
npm install -g @google/gemini-cli
gemini --version
FAQ
Can I use a GPT or Claude model here?
Gemini CLI uses the native Gemini protocol. Use Codex for Responses or Claude Code for Messages.
Which settings file is edited?
The tool edits user-level files in .gemini. See the official configuration reference for project and environment precedence.
Troubleshooting
401 / authentication failed
The active credential is incomplete, revoked, or still points to another provider.
Paste a valid UniRoute key and check the active authentication method.
404 / wrong endpoint
The base URL and adapter path do not match.
Use the address shown above and remove duplicated /v1 or /v1beta segments.
Model missing / 403
The selected model, key permissions, or wallet funds need attention.
Check the model ID, key restrictions, and wallet in the console, then restart the client.
Changes did not take effect
A running process or a different config directory is still in use.
Quit the client completely, check its effective configuration path, then reopen.
Related links
Manage API keys
Model prices
