Agents & Editors
Gemini CLI
Connecting Google's Gemini CLI to a Gemini Proxy with the Gemini generateContent format.
Gemini CLI is Google's coding agent for the terminal. It sends Gemini API requests only, so it connects to Multi-Router through a Gemini Proxy, which serves Gemini's generateContent and streamGenerateContent for Gemini models with the organization's Gemini key.
Creating the router
- In Provider Keys, add or enable a Gemini key for the organization.
- In Routers, choose New router, then Gemini Proxy, name it, and choose the organization's Gemini key. A Gemini Proxy uses the Organization credential only.
- Create the router. Its id, such as
rt_XXXXXXXX, is on the router's page, under Forwarding with the Gemini CLI settings. - In API Keys, create a key with the
inferencescope for each developer. It can be limited to this router.
Settings
Gemini CLI reads its gateway settings from environment variables:
| Variable | Value |
|---|---|
GOOGLE_GEMINI_BASE_URL | The Multi-Router address, with no path. Gemini CLI adds the Gemini API paths. |
GEMINI_API_KEY | The Multi-Router API key, which Gemini CLI sends in the x-goog-api-key header. The organization's Gemini key stays in Multi-Router. |
GEMINI_CLI_CUSTOM_HEADERS | Extra headers as Name: value, separated by commas. |
A Google account sign-in does not go through a Gemini Proxy. Set Gemini CLI's sign-in method to the Gemini API key in ~/.gemini/settings.json; without it, Gemini CLI stops with Invalid auth method selected:
Gemini CLI only approves tool calls automatically (--yolo) in a folder you have trusted. Run it in a trusted folder, or it asks before each tool call.
Models
A Gemini Proxy serves Gemini models only, named as Google names them, such as gemini-2.5-flash, chosen with -m or GEMINI_MODEL. It serves content generation and streaming; other Gemini API operations, such as token counting, are not served.
Checking the setup
The request then appears in Traffic with the Gemini Proxy in the Router column and the model, tokens and cost in the request detail. A reply with the requested model or router was not found means the router id is wrong, or the API key is not allowed to use that router. See Traffic and Troubleshooting.