Skip to Content
aicentos

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 -v

Install Gemini CLI

Install Gemini CLI globally with npm:

npm install -g @google/gemini-cli

Verify the installation:

gemini --version

Configure environment variables

Gemini CLI supports connecting to a custom gateway through the following three environment variables:

Environment variableDescription
GOOGLE_GEMINI_BASE_URLRoot address of the gateway service; replaces Google's default endpoint
GEMINI_API_KEYYour API Key
GEMINI_MODELThe 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_URL takes 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 ~/.zshrc or ~/.bashrc, then run source ~/.zshrc to apply them

Launch Gemini CLI

Once configured, start it by running:

gemini

After 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_KEY is correct
  • Check that GOOGLE_GEMINI_BASE_URL points 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