Gemini CLI + Cradler Router

How to run Gemini CLI on a cheaper API

Gemini CLI takes a custom base URL and key from the environment. Send it to Cradler Router — a native Gemini API gateway — for cheaper access to the Gemini models, topped up in your own currency, with no Google account required.

Short answer

Gemini CLI speaks the native Gemini API. Set GOOGLE_GEMINI_BASE_URL to Cradler Router, GEMINI_API_KEY to your Router key, and GEMINI_API_KEY_AUTH_MECHANISM=bearer, and the CLI runs as before — same commands, streaming intact — on cheaper supply. No Google account needed.

One command, every agent

Paste your key, copy the command, run it in a terminal. It writes the config for Claude Code, Codex, and Gemini CLI — plus OpenClaw, ZCode, and Cherry Studio when they're installed — then verifies your key against the Router. Built locally; the key never leaves this page.

npx @cradler/router-setup <your-router-key>

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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
gemini

Under 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.

The rest of what your Cradler account includes

Router makes Gemini CLI cheaper. The same account also gives the app you're building a full backend.

Data

Managed PostgreSQL

Auto-evolving schema. No SQL, no migrations, no ALTER TABLE.

Storage

Image / video / audio storage

Through the same SDK as your data, served fast over a global CDN.

DX

Typed TypeScript SDK

@cradler/sdk — query-builder shape your AI tool was trained on.

AI-native

MCP server

@cradler/mcp — Claude and Cursor read and write your data directly.

AI-native

Agent Skill

Drop into your AI agent; it knows how to wire Cradler in.

Frequently asked questions

Do I need a Google AI Studio account or key to use Gemini CLI?

No. Gemini CLI needs a Gemini-compatible endpoint and a key. Cradler Router exposes the native Gemini API, so you point the CLI at Router with your Cradler key and top up by card (Alipay and WeChat Pay coming soon). No separate Google signup.

Which endpoint and auth does Gemini CLI use through Router?

Router serves the native Gemini format: POST /v1beta/models/{model}:generateContent, with streaming via streamGenerateContent?alt=sse. Authenticate with a Bearer token (the Gemini native endpoint also accepts the x-goog-api-key header). Set GEMINI_API_KEY_AUTH_MECHANISM=bearer so the CLI sends the right header.

Does streaming work?

Yes. Native Gemini streaming (streamGenerateContent with alt=sse) passes through, so the CLI shows tokens as they arrive rather than waiting for the whole response.

My Gemini SDK uses a different field name for the base URL.

That is normal — SDKs differ. The field may be base_url, baseURL, apiEndpoint, or an environment variable. The principle is the same: point the base URL at the Cradler Router endpoint and use your Router key. Check your specific SDK's docs for the exact field name.

Which Gemini models are available?

The Gemini 3.x line is available, including flash and pro variants and an image model. The authoritative list is always what GET /v1/models returns for your key — read that rather than hard-coding a model name.

How does this connect to Cradler's database?

Cradler Router and Cradler's database + file storage are two features of one account. Use Router on its own for cheaper Gemini access, or use the same project to give the app you're building a managed PostgreSQL database and file storage through a typed SDK — no SQL, no migrations.

Keep reading

Run Gemini CLI for less

Create a Cradler account, get a Router key, and set three environment variables. Free to start — top up in your own currency.