Gemini CLI
Use aicentos in Gemini CLI — configure a custom gateway through environment variables
Last updated:
Gemini CLI is an official command-line tool from Google that supports configuring a custom gateway through environment variables to connect to the Codex Proxy service, letting you chat with Gemini models in the terminal.
Prerequisites
Gemini CLI is installed globally via npm, so you need Node.js 18+ and npm ready first.
Install Node.js
- Visit the official Node.js download page: https://nodejs.org/en/download
- macOS/Windows: download and install the LTS version
- Linux: install using the distro instructions on that page
- macOS (Homebrew users): run
brew install node
Verify the installation
node -v
npm -vInstall Gemini CLI
Install Gemini CLI globally with npm:
npm install -g @google/gemini-cliVerify the installation:
gemini --versionConfigure environment variables
Gemini CLI supports connecting to a custom gateway through the following three environment variables:
| Environment variable | Description |
|---|---|
GOOGLE_GEMINI_BASE_URL | Root address of the gateway service; replaces Google's default endpoint |
GEMINI_API_KEY | Your API Key |
GEMINI_MODEL | The default model to use |
Example configuration
export GOOGLE_GEMINI_BASE_URL="https://aicentos.com"
export GEMINI_API_KEY="your_api_key_here"
export GEMINI_MODEL="gemini-2.0-flash"Notes
GOOGLE_GEMINI_BASE_URLtakes the service root address; no specific API path is needed- Quick tests: run the export commands above directly in the current shell session
- To persist: add the export statements to
~/.zshrcor~/.bashrc, then runsource ~/.zshrcto apply them
Launch Gemini CLI
Once configured, start it by running:
geminiAfter launching, you can chat with Gemini models right in the terminal.
Verify the connection
Start a conversation in Gemini CLI; if replies come back normally, the integration is working.
Troubleshooting
- For authentication errors, confirm that
GEMINI_API_KEYis correct - Check that
GOOGLE_GEMINI_BASE_URLpoints to the correct service address
Notes
- The service already supports the Gemini-compatible interface and works with Gemini CLI directly
- Add the environment variables to a shell configuration file so they persist
- Gemini CLI appends the API path automatically; there is no need to add a specific API path to the BASE_URL
Related links
- Official documentation: https://docs.aicentos.com/clients/gemini-cli.html