Why route Gemini CLI
Gemini CLI calls the native Gemini API. Routing it through a compatible gateway keeps the exact same request format while changing where it goes and what it costs — and it drops the requirement for a Google account and card.
Cradler Router exposes the native generateContent endpoint, so the CLI does not know it is talking to a gateway. Streaming, model selection, and the rest of the CLI behave identically.
Connecting Gemini CLI to Cradler Router, step by step
Three environment variables — that is the whole integration.
- 01
Create a Cradler account and get a Router key
Sign up at cradler.ai, open the Router section, top up by card, and create an API key. The same account also runs your Cradler database and file storage.
- 02
Configure Gemini CLI
Fastest: run npx @cradler/router-setup with your key — it writes the config and verifies the key for you. Or set three environment variables manually: the Cradler Router base URL, your Router key, and Bearer authentication.
- 03
Pick a Gemini model
Run Gemini CLI as usual, or select a model such as gemini-3.5-flash or gemini-3.1-pro-preview. Use /v1/models to see which Gemini model IDs your key can reach.
- 04
Build — streaming and all
Native Gemini requests, including streaming (streamGenerateContent with alt=sse), pass straight through. You get the same CLI at cheaper per-token rates.
The configuration
Set the three variables in your shell (or shell profile) and run the CLI from the same terminal:
# Point Gemini CLI at Cradler Router
export GOOGLE_GEMINI_BASE_URL="https://router.cradler.ai"
export GEMINI_API_KEY="<your-router-key>"
export GEMINI_API_KEY_AUTH_MECHANISM="bearer"
# Run Gemini CLI as usual
geminiUnder the hood the CLI calls /v1beta/models/{model}:generateContent against Router. A raw request looks like this:
curl "https://router.cradler.ai/v1beta/models/gemini-3.5-flash:generateContent" \
-H "Authorization: Bearer <your-router-key>" \
-H "content-type: application/json" \
-d '{
"contents": [
{ "role": "user", "parts": [{ "text": "Explain what an API gateway is." }] }
]
}'Gotchas worth knowing
Set the auth mechanism to bearer. Router authenticates Gemini requests with a Bearer token. If the CLI defaults to a query-string key, set GEMINI_API_KEY_AUTH_MECHANISM=bearer so the key goes in the header. The native endpoint also accepts x-goog-api-key.
SDK field names vary. If you are wiring a Gemini SDK rather than the CLI, the base-URL field might be base_url, baseURL, or apiEndpoint. Point whichever one at Router.
Read the model list, don't guess it. Available Gemini model IDs are whatever /v1/models returns for your key. Mind the dots and dashes in version names.
One account, model access and a backend
Cradler Router is part of Cradler — the same account that gives your app a managed PostgreSQL database and file storage through a typed SDK, with no SQL and no migrations. One signup covers cheaper model access and the backend for whatever you build.