Agentsflare Gemini CLI Configuration Guide
Gemini CLI is Google's official open-source terminal coding agent.
Installing and Configuring Gemini CLI
Installing Gemini CLI
Run directly with npx (no installation required):
npx @google/gemini-cliInstall globally with npm:
npm install -g @google/gemini-cliInstall with Homebrew (macOS/Linux):
brew install gemini-cliFor other installation methods, refer to the official documentation Gemini CLI Installation
Configuring Gemini CLI
Gemini CLI supports overriding the API base URL through environment variables, which allows it to connect to the Agentsflare gateway via the Google Generative AI interface.
Add the following to your shell profile (~/.bashrc, ~/.zshrc, etc.):
export GEMINI_API_KEY="Your Agentsflare API key"
export GOOGLE_GEMINI_BASE_URL="https://api.agentsflare.com/google"
export GOOGLE_GENAI_API_VERSION="v1"Windows PowerShell:
$env:GEMINI_API_KEY="Your Agentsflare API key"
$env:GOOGLE_GEMINI_BASE_URL="https://api.agentsflare.com/google"
$env:GOOGLE_GENAI_API_VERSION="v1"Configuration description:
| Environment Variable | Description |
|---|---|
GEMINI_API_KEY | Your Agentsflare API key (obtained from the Agentsflare console) |
GOOGLE_GEMINI_BASE_URL | Overrides the default Gemini API base URL, pointing to the Agentsflare Google interface |
GOOGLE_GENAI_API_VERSION | Forces the API version to v1, matching the Agentsflare endpoint path /google/v1/models/ |
Optionally, specify the default model (otherwise the CLI built-in default is used):
export GEMINI_MODEL="gemini-3-flash-preview"Restart your terminal (or source the profile) for the configuration to take effect, then run:
geminiCommon Issues
Connection fails or requests still go to Google official servers
Make sure GOOGLE_GEMINI_BASE_URL is set and the terminal has been restarted. Gemini CLI requires the custom base URL to use HTTPS (except for localhost). You can verify the current environment variables with:
echo $GOOGLE_GEMINI_BASE_URL404 Not Found or path errors
The Agentsflare Google interface path is /google/v1/models/. Gemini CLI uses API version v1beta by default — you must set GOOGLE_GENAI_API_VERSION="v1", otherwise the CLI will request a v1beta path that the gateway does not provide.
How to switch models
Specify the model through the startup parameter or environment variable:
gemini --model gemini-3.5-flashAvailable Gemini models are listed in Supported Models.
