Use a custom Gemini Base URL (Antigravity CLI, Gemini CLI, OpenCode)

How to point Google Antigravity CLI (agy), Gemini CLI, the official @google/genai SDK, and OpenCode's google provider at a Gemini-native API endpoint. The usual mistake is whether /v1beta belongs on the Base URL.

I run qcode.cc, an independent API service (not official Anthropic, OpenAI, or Google). The command examples below use QCode's published paths; swap the host if you use another Gemini-compatible gateway. Full reference: Endpoints and API paths · Antigravity CLI · tool compatibility.

1. Which Base URL to paste

The Gemini generateContent path is /v1beta/models/{model}:generateContent. Some clients append /v1beta themselves. If you also put it on the Base URL, the request becomes /gemini/v1beta/v1beta/... and returns 404.

ClientSettingBase URLClient then calls
Antigravity CLI (agy), Gemini CLI, @google/genaiGemini base URLhttps://api.qcode.cc/gemini/v1beta/models/{model}:generateContent
OpenCode google providerprovider.google.options.baseURLhttps://api.qcode.cc/gemini/v1betait does not append /v1beta

The same paths work on https://asia.qcode.cc and https://us.qcode.cc. Do not add a trailing slash on the Base URL. A QCode key starts with cr_ and is not protocol-specific: the path you call decides the protocol (Anthropic, OpenAI, or Gemini).

On QCode, Gemini models (currently gemini-4-neon) are available only on the Gemini path — not on /api or /openai. Claude stays on Anthropic; GPT stays on OpenAI. Live models and prices: qcode.cc/models. As of 2026-12-04, gemini-4-neon is listed at $3 / $15 per 1M tokens (implicit cache read $0.15, 1M context, service rate ×1.0). gemini-4-carbon, gemini-4-argon, and gemini-4-hydrogen are not listed.

2. Antigravity CLI, Gemini CLI, and the official SDK

Gemini CLI stopped serving personal / Pro login plans on 2026-06-18 (Google's announcement); API-key mode still works, and Antigravity CLI (agy) is the successor CLI. Configure the base URL without /v1beta:

export GOOGLE_GEMINI_BASE_URL="https://api.qcode.cc/gemini"
export GEMINI_API_KEY="cr_your_key"
export GEMINI_MODEL="gemini-4-neon"

agy also reads ~/.gemini/antigravity-cli/settings.json (Windows: %USERPROFILE%\.gemini\antigravity-cli\settings.json). It needs both fields, and model must be the display name, not the raw id:

{
  "modelProvider": "gemini",
  "model": "Gemini 4 Neon (High)"
}

Leaving out model, or writing gemini-4-neon, makes agy fall back to another default model and return 404. Only the CLI supports a custom endpoint; the desktop Antigravity IDE does not. More detail and a troubleshooting table: Antigravity CLI page.

For a one-command setup of Claude Code, Codex CLI, and Antigravity CLI together, use QCode's one-click install.

3. OpenCode google provider

Full OpenCode page (Anthropic, OpenAI and google providers): OpenCode setup.

OpenCode does not append /v1beta, so the Base URL must include it:

{
  "provider": {
    "google": {
      "options": {
        "baseURL": "https://api.qcode.cc/gemini/v1beta"
      }
    }
  }
}

Put this in OpenCode's config (typically ~/.config/opencode/opencode.json). If a 404 appears, check that you did not also add a second /v1beta.

4. curl check

A missing body should return HTTP 400 if the path and key are accepted, or 401 if the key is rejected. HTTP 404 means the prefix is wrong.

export KEY="cr_your_key"

# model list
curl -s "https://api.qcode.cc/gemini/v1beta/models" -H "x-goog-api-key: $KEY"

# path check (no body on purpose)
curl -s -o /dev/null -w '%{http_code}\n' -X POST \
  "https://api.qcode.cc/gemini/v1beta/models/gemini-4-neon:generateContent" \
  -H "x-goog-api-key: $KEY"

# a real ping
curl -s "https://api.qcode.cc/gemini/v1beta/models/gemini-4-neon:generateContent" \
  -H "x-goog-api-key: $KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"parts":[{"text":"ping"}]}]}'

5. Claude Code and Codex on the same key

The same cr_ key can call the other two protocols by path:

ClientBase URLNotes
Claude Codehttps://api.qcode.cc/apiANTHROPIC_BASE_URL; do not add /v1
Codex CLIhttps://api.qcode.cc/openaibase_url plus wire_api = "responses"
OpenAI Chat Completions SDKshttps://api.qcode.cc/openai/v1appends /chat/completions

Codex details: Codex CLI page. Step-by-step for those two clients: custom Base URL guide. Pricing (no free quota; personal plans from $9 / ¥63 for 30 days, usage packs from $4 / ¥26 for 7 days): qcode.cc/pricing. Contact: hi@qcode.cc.

Related: troubleshooting · environment variables · Cursor and Cline · evaluate a relay · cheat sheet.

Facts checked against QCode docs and models pages on 2026-12-04. I run qcode.cc.