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.
Configuration
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/v1gemini from your terminal.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
Create a key
Register at api.oairoute.com and create a key on the token page.
- 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
Verify
Run `gemini "list every Markdown file here"` and check it answers.
Models worth trying
| Model ID | Name | Use it for | USD per 1M in / out |
|---|---|---|---|
gemini-4-argon | Gemini 4 Argon | 1M context, strongest Gemini here. | $0.30 / $1.50 |
gemini-3-pro-image | Gemini 3 Pro Image | Image generation and editing, 65K context. | $0.30 / $1.80 |
claude-sonnet-5-5 | Claude Sonnet 5.5 | Same 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.