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
Section titled “Install”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-cliOn macOS / Linux you can also use Homebrew:
brew install gemini-cliTo try it without a global install:
npx @google/gemini-cliCheck the install:
gemini --versionIf it prints a version number, you are set. System requirements and other install methods are in the official installation guide.
Before you start
Section titled “Before you start”- 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.
- Open the console API Keys page, choose Terminal Commands in the action menu of the token you want, and pick the Gemini CLI tab.
- Pick a model and your system (macOS / Linux, Windows CMD or PowerShell).
- 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 |
Option 2: set them by hand
Section titled “Option 2: set them by hand”macOS / Linux:
export GOOGLE_GEMINI_BASE_URL=https://api.openpalm.aiexport GEMINI_API_KEY=sk-xxxxexport GEMINI_MODEL=YOUR_MODELgeminiWindows PowerShell:
$env:GOOGLE_GEMINI_BASE_URL = "https://api.openpalm.ai"$env:GEMINI_API_KEY = "sk-xxxx"$env:GEMINI_MODEL = "YOUR_MODEL"geminiReplace 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.
Check it works
Section titled “Check it works”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.
Common problems
Section titled “Common problems”| 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.