Run Gemini CLI on OAIRoute

Gemini CLI speaks the Gemini native API, not OpenAI. OAIRoute serves that shape too, so one environment variable is enough to route it through the gateway.

Google

Configuration

~/.gemini/.env
GEMINI_API_KEY=YOUR_OAIROUTE_KEY
GOOGLE_GEMINI_BASE_URL=https://api.oairoute.com

# Or use it in OpenAI-compatible mode:
OPENAI_API_KEY=YOUR_OAIROUTE_KEY
OPENAI_BASE_URL=https://api.oairoute.com/v1
Then run gemini from your terminal.

Full step-by-step guide

Why route it through OAIRoute

Gemini 4 at a fraction of list

Gemini 4 Argon costs $0.30 in / $1.50 out per million tokens here, against $2.00 / $10.00 from Google.

Native Gemini shape, not a translation layer

Requests hit /v1beta/models/...:generateContent and come back in Gemini format, so the CLI parses them normally.

Fall back to OpenAI-compatible mode

The same key also works through /v1/chat/completions when you want to compare Gemini against another vendor on the same prompt.

Setup

  1. 1

    Create a key

    Register at api.oairoute.com and create a key on the token page.

  2. 2

    Set the base URL

    Export GOOGLE_GEMINI_BASE_URL alongside GEMINI_API_KEY. Note that the CLI reads GEMINI_API_KEY, not GOOGLE_API_KEY.

  3. 3

    Verify

    Run `gemini "list every Markdown file here"` and check it answers.

Models worth trying

Model IDNameUse it forUSD per 1M in / out
gemini-4-argonGemini 4 Argon1M context, strongest Gemini here.$0.30 / $1.50
gemini-3-pro-imageGemini 3 Pro ImageImage generation and editing, 65K context.$0.30 / $1.80
claude-sonnet-5-5Claude Sonnet 5.5Same key, useful for a second opinion.$0.18 / $0.90

Prices are per million tokens, input / output, at the rates published in the model catalogue.

Questions

Why "API key not valid"?

Gemini CLI reads GEMINI_API_KEY. If you set GOOGLE_API_KEY instead, it never sees the value.

Some built-in tools do not work. Why?

Features that depend on Google-side services — the built-in search tool for example — are not proxied. Core conversation and file tools work.

Is the request format really Gemini-native?

Yes: camelCase parameters such as maxOutputTokens, roles limited to user and model, and no OpenAI tool_calls field.

Other guides