Gemini CLI Custom Endpoint: Install It and Connect a Relay
Gemini CLI is Google's open-source terminal agent. This guide follows the same layout as our Codex CLI guide: the official install and update commands, then how to send its requests to a relay instead of Google's own address. Every command and setting below comes from Google's documentation, linked at the bottom.
Read this first: who Gemini CLI is for now (as of November 2026)
The README in the google-gemini/gemini-cli repository opens with a status notice. It says Gemini CLI is designed for Gemini Code Assist Standard / Enterprise licenses and Code Assist for GitHub on Google Cloud, that free individual access and Google AI Pro / Ultra moved to Antigravity CLI on June 18, 2026, and that it is not tuned for the Gemini 4 series. Its comparison table lists Gemini CLI for organizations with Code Assist, "plus legacy paid API / Vertex keys". A relay setup uses the API-key route, so read that notice and decide whether Gemini CLI is the right tool before you spend time on it.
How to install Gemini CLI
Google's installation page lists a Node.js 20.0.0+ runtime and these install methods:
# npm
npm install -g @google/gemini-cli
# Homebrew (macOS / Linux)
brew install gemini-cli
# MacPorts (macOS)
sudo port install gemini-cli
# or run it without installing
npx @google/gemini-cliStart it with gemini in your project directory. To pick a model for one run, the README shows gemini -m gemini-2.5-flash.
Gemini CLI custom endpoint: set the base URL and key
In the configuration reference, GEMINI_API_KEY holds your API key and GOOGLE_GEMINI_BASE_URL overrides the default base URL for Gemini API requests when you use gemini-api-keyauthentication. Put your relay's values in both:
export GEMINI_API_KEY="your-relay-key"
export GOOGLE_GEMINI_BASE_URL="https://your-relay-domain"
geminiThree details from the same page. The base URL must be a valid URL and must use HTTPS unless it points to localhost, 127.0.0.1 or [::1]. The docs' own example is a bare host (https://my-proxy.com), so use exactly the address your relay documents for Gemini-format requests. And the docs say to set the key in your shell profile (for example ~/.zshrc) or in an .env file. The default model can also be set with GEMINI_MODEL.
Then run a small prompt, such as asking it to summarize one local file, to confirm you get a normal reply. A reply shows that the endpoint answers, not which model is behind it; our verification tool checks that.
Updating Gemini CLI
The README and installation page describe three release channels. Stable is the default; the others are for testing:
# latest stable release
npm install -g @google/gemini-cli@latest
# weekly preview (not fully vetted)
npm install -g @google/gemini-cli@preview
# nightly
npm install -g @google/gemini-cli@nightlyWhat to check before choosing a relay for Gemini CLI
Does the relay accept Gemini-format requests?
The base URL setting only changes where Gemini CLI sends its Gemini API requests. A relay that exposes only an OpenAI-style endpoint is not something this setting can use. Look for a Gemini or Google GenAI section in the relay's own docs and use exactly the address it gives you.
Is the model ID you want on the relay's list?
You pick the model with the -m flag or the GEMINI_MODEL variable, so the ID has to match one the relay serves. Check the relay's model list before you fund the account.
Does it forward what you need?
If you plan to pass images or very long files, send a small test with those inputs first. Some relays pass text through fine and handle other inputs differently.
To see which tracked relays carry Gemini models, browse the Gemini relays list and compare prices on the Gemini 3.1 Pro price page.
Official sources used
FAQ
Can Gemini CLI use a custom base URL?
Yes. Google's configuration reference documents GOOGLE_GEMINI_BASE_URL, which overrides the default base URL for Gemini API requests when you authenticate with a Gemini API key. The value must be a valid URL and must use HTTPS unless it points to localhost.
Does Gemini CLI work with an OpenAI-compatible relay?
The documented setting changes the address of Gemini API requests, and the docs do not describe any conversion from another API format. So the relay needs to accept Gemini-format requests at the address you give. If a relay documents only an OpenAI-style endpoint, ask its support whether it also offers a Gemini-format one.
Is Gemini CLI still free to use?
Its README says free individual access and Google AI Pro / Ultra plans moved to Antigravity CLI on June 18, 2026, and that Gemini CLI is now aimed at Gemini Code Assist Standard / Enterprise and Code Assist for GitHub on Google Cloud, plus legacy paid API and Vertex keys. Check the README for the current position before you set it up.
How do I update Gemini CLI?
If you installed it with npm, Google's docs give npm install -g @google/gemini-cli@latest for the latest stable release, with the preview and nightly tags available for earlier builds.