N·03Integration guides
Gemini CLI
Google's command-line AI agent, speaking the native Gemini protocol; set a few environment variables to route requests to XylemNode.
- 01
Install and verify
Install globally with npm (recommended); on macOS you can use Homebrew, or run it install-free with npx for a quick try. After installing, print the version to confirm.
terminal # npm (recommended, all platforms)
npm install -g @google/gemini-cli# macOS Homebrew
brew install gemini-cli# Run without installing
npx @google/gemini-cli# Verify
gemini --version - 02
Set environment variables
Gemini CLI connects to custom services via environment variables — set three: endpoint, API key and default model. For the endpoint, the service domain is enough. On Windows, run setx and reopen the terminal; on macOS / Linux, export only lasts for the current terminal, so add the three lines to the end of ~/.zshrc (or ~/.bashrc), or use the .env file in the next step.
terminal # Windows (PowerShell / CMD)
setx GOOGLE_GEMINI_BASE_URL "https://api.xylemnode.com" setx GEMINI_API_KEY "sk-your-key" setx GEMINI_MODEL "gemini-4-argon"# macOS / Linux
export GOOGLE_GEMINI_BASE_URL="https://api.xylemnode.com" export GEMINI_API_KEY="sk-your-key" export GEMINI_MODEL="gemini-4-argon" - 03
Or use a .env file
If you'd rather not set system variables, put these in a .env file that Gemini CLI loads on start. Note that it only loads the first .env it finds, searching upward from the current folder: when a project already has its own .env, the one in your user directory isn't read, so add the three lines to the project's .env too. A project's .env only takes effect in a folder you've trusted.
- Windows
%USERPROFILE%\.gemini\.env- macOS / Linux
~/.gemini/.env- Project-level
<project-root>/.gemini/.env
.env GOOGLE_GEMINI_BASE_URL=https://api.xylemnode.com GEMINI_API_KEY=sk-your-key GEMINI_MODEL=gemini-4-argon - 04
Launch and test
Run gemini (in a new terminal if you used setx). On the first start it asks whether to trust the current folder and how to sign in: trust the folder and choose Use Gemini API key; if you picked Google sign-in before, type /auth inside gemini to change it. You can also pick a model for the run with -m; for a non-interactive check with -p, run it in a folder you've already trusted.
terminal gemini# Pick a model for this run / non-interactive check
gemini -m gemini-4-argon -p "Reply with OK only"
Common questions
Gemini CLI still logs in with a Google account despite the environment variables — or won't switch back
It follows the sign-in method it saved: the choice you made on the first start is remembered, so setting GEMINI_API_KEY later doesn't necessarily switch it. If you want XylemNode but it still uses your Google account, type /auth inside gemini and choose Use Gemini API key; if it still doesn't see the key after that, the process probably never got it (writing it with setx and not reopening the terminal is the classic case). To go back to a Google account, also start with /auth; if that doesn't take, clear GEMINI_API_KEY from the environment and from .env, then clear the cached credentials. Worth knowing: CC Switch configures Gemini through those same environment variables, which pins the CLI to API-key mode, and uninstalling CC Switch does not undo it.