Skip to content

Gemini CLI

Gemini CLI can be pointed at a custom Gemini API address through an environment variable. OpenPalmLab provides a Gemini-compatible endpoint (/v1beta/models/...), so the setup below is all you need.

Install Gemini CLI first, then follow the steps below to connect it to the gateway. The install method from the official README (Node.js required):

终端窗口
npm install -g @google/gemini-cli

On macOS / Linux you can also use Homebrew:

终端窗口
brew install gemini-cli

To try it without a global install:

终端窗口
npx @google/gemini-cli

Check the install:

终端窗口
gemini --version

If it prints a version number, you are set. System requirements and other install methods are in the official installation guide.

  • Gemini CLI is installed.
  • You have a console token whose group includes Gemini models (see the pricing page).

Option 1: generate the config in the console

Section titled “Option 1: generate the config in the console”

The console builds the config in your browser; your token never leaves it.

  1. Open the console API Keys page, choose Terminal Commands in the action menu of the token you want, and pick the Gemini CLI tab.
  2. Pick a model and your system (macOS / Linux, Windows CMD or PowerShell).
  3. Copy the commands from the dialog and run them in your terminal. They apply to the current session only.

The dialog generates these variables (GEMINI_MODEL is left out when the model field is empty):

Variable Value
GOOGLE_GEMINI_BASE_URL https://api.openpalm.ai (no /v1beta; Gemini CLI appends the path itself)
GEMINI_API_KEY sk-xxxx
GEMINI_MODEL the model you picked

macOS / Linux:

终端窗口
export GOOGLE_GEMINI_BASE_URL=https://api.openpalm.ai
export GEMINI_API_KEY=sk-xxxx
export GEMINI_MODEL=YOUR_MODEL
gemini

Windows PowerShell:

终端窗口
$env:GOOGLE_GEMINI_BASE_URL = "https://api.openpalm.ai"
$env:GEMINI_API_KEY = "sk-xxxx"
$env:GEMINI_MODEL = "YOUR_MODEL"
gemini

Replace YOUR_MODEL with a model name from the pricing page that your group can use. The official configuration reference says GOOGLE_GEMINI_BASE_URL must be an HTTPS address (local addresses excepted); OpenPalmLab meets that.

To make the settings permanent, put these lines in an .env file that Gemini CLI loads (the official configuration reference says it loads .env from the current directory, parent directories or your home directory, and also supports .gemini/.env). The file holds your token, so do not commit it to a repository.

Start gemini and ask anything. Then open the console Usage Logs page; a request record for your token means it works. You can also first confirm the token and model with the Gemini example on the curl page.

Symptom Fix
It asks you to log in or pick an auth method GEMINI_API_KEY was not picked up. Check the variable in the same terminal, or choose the Gemini API key option when it asks.
401 The token is wrong, expired or out of quota.
404 GOOGLE_GEMINI_BASE_URL has extra path. Use only https://api.openpalm.ai.
No available channel for model ... That model has no available channel in your group. Choose another model, or use a token in a different group.

See Troubleshooting for more. Similar clients: Claude Code, Codex CLI, OpenCode.