Gemini CLI API Gateway

Connect Gemini CLI to gw-link with GOOGLE_GEMINI_BASE_URL

Gemini CLI uses the native Gemini API (/v1beta). gw-link serves a compatible /v1beta endpoint: point GOOGLE_GEMINI_BASE_URL at the gateway root, put your console-issued key in GEMINI_API_KEY, and use Gemini models from the terminal on the same account as Claude Code and Codex.

Get started · View pricing

Native Gemini protocol

gw-link serves /v1beta directly and accepts x-goog-api-key auth, so Gemini CLI needs no format translation.

One account across tools

Claude Code, Codex and Gemini CLI share one gw-link account, each with its own key and one balance.

Just two settings

GOOGLE_GEMINI_BASE_URL and GEMINI_API_KEY — add them to your shell profile to make them permanent.

How to connect Gemini CLI

  1. Create a key in the gw-link console (Gemini group) and open Use Key → Gemini CLI.
  2. Set GOOGLE_GEMINI_BASE_URL=https://gw-link.com (no /v1beta) and GEMINI_API_KEY.
  3. Run gemini; if asked how to authenticate, choose Use Gemini API Key.
  4. Send a message to confirm the model responds.

Configuration examples

macOS / Linux shell

Optional: export GEMINI_MODEL=<model> to set a default; use a model your console lists.

export GOOGLE_GEMINI_BASE_URL="https://gw-link.com"
export GEMINI_API_KEY="sk-your-gw-link-key"
gemini

FAQ

Should GOOGLE_GEMINI_BASE_URL include /v1beta?

No. Gemini CLI appends /v1beta/models/... itself; use https://gw-link.com.

Do I need to sign in with a Google account?

No. With GEMINI_API_KEY set, Gemini CLI authenticates with that key — the one issued by gw-link.

Is an API gateway a good fit for Gemini CLI?

Yes, especially when a team wants one place to manage keys, quotas and spend across several AI coding tools.

中文版

Last updated: