Bottom line
Gemini CLI cannot connect to CodeGateway directly.
Gemini CLI (Google's official open-source terminal agent, verified against 0.58.0) supports a custom upstream URL, but only the Gemini-native API protocol (e.g. generateContent endpoints). CodeGateway surfaces are Anthropic Messages and OpenAI-compatible protocols — there is no Gemini-native surface — so a direct connection is not possible.
Why
Gemini CLI's endpoint override is the env var
GOOGLE_GEMINI_BASE_URL(withGEMINI_API_KEY), and the official config docs require the URL to serve the Gemini API protocol.CodeGateway's surfaces: Anthropic Messages (
/v1/messages), OpenAI Chat Completions (/v1/chat/completions), OpenAI Responses (/v1/responses). There is no:generateContent-style endpoint (verified: 404).Important distinction: Gemini models in CodeGateway's catalog (e.g.
gemini-3.8-flash) are usable — but through tools that speak the Anthropic Messages protocol (see below).
Alternative 1: You still want Gemini models
Use Claude Code against CodeGateway and switch the model to a Gemini-series one (gemini-3.8-flash is verified working on the Anthropic Messages protocol):
export ANTHROPIC_BASE_URL="https://api.codegateway.dev"
export ANTHROPIC_AUTH_TOKEN="sk-cg-your-key"
# In ~/.claude/settings.json, set model to gemini-3.8-flashFull steps: Claude Code one-line setup.
Alternative 2: You want a terminal coding agent
Pick a mainstream OpenAI-compatible tool and use CodeGateway's DeepSeek / Kimi / GLM / Qwen models:
Qwen Code integration: one
~/.qwen/settings.jsonedit and you're set.Or opencode / Aider / Crush / Codex CLI — entries in the Agent CLI overview.
Possible future changes
If CodeGateway adds a Gemini-native surface (or Gemini CLI adds an OpenAI/Anthropic-compatible provider mode), this page will be updated immediately.
FAQ
Q: Can I use Gemini models on CodeGateway? Yes. Gemini-series models work on the Anthropic Messages protocol (gemini-3.8-flash recommended) — just not via Gemini CLI itself.
Q: What happens if I point GOOGLE_GEMINI_BASE_URL at api.codegateway.dev? Requests hit a non-existent Gemini-native endpoint and fail (404 or protocol mismatch). Please don't.
Q: Are there community relay workarounds? Some communities reverse-proxy the Gemini protocol; the supported paths are the two alternatives above — they use CodeGateway's official surfaces with billing and troubleshooting in one place.
Q: Will Gemini CLI ever support OpenAI compatibility? No official statement so far. Watch this page for updates.