Skip to content

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):

bash
npx @google/gemini-cli

Install globally with npm:

bash
npm install -g @google/gemini-cli

Install with Homebrew (macOS/Linux):

bash
brew install gemini-cli

For 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.):

bash
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:

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 VariableDescription
GEMINI_API_KEYYour Agentsflare API key (obtained from the Agentsflare console)
GOOGLE_GEMINI_BASE_URLOverrides the default Gemini API base URL, pointing to the Agentsflare Google interface
GOOGLE_GENAI_API_VERSIONForces 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):

bash
export GEMINI_MODEL="gemini-3-flash-preview"

Restart your terminal (or source the profile) for the configuration to take effect, then run:

bash
gemini

Common 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:

bash
echo $GOOGLE_GEMINI_BASE_URL

404 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:

bash
gemini --model gemini-3.5-flash

Available Gemini models are listed in Supported Models.

This documentation is licensed under CC BY-SA 4.0.