Skip to main content

Overview

Gemini CLI is Google’s open-source command-line AI agent for developers. It connects directly to Gemini models and can understand your codebase, generate code, run commands, and assist with complex development tasks. By configuring Gemini CLI to use FoxAPI, you can access Gemini models through FoxAPI’s API infrastructure.
Gemini CLI does not natively support custom base URLs. Configuration requires modifying source files inside the installed package. This modification may need to be reapplied after updating the package.

Prerequisites

FoxAPI API Key

An active FoxAPI API key with access to Gemini models.

Node.js 20+

Node.js v20 or later and npm are required for installing Gemini CLI.

Installation & Configuration

1

Install Gemini CLI

npm install -g @google/gemini-cli
2

Set Your API Key

Add your FoxAPI API key to your shell profile (~/.bashrc, ~/.zshrc, etc.):
export GEMINI_API_KEY="sk-your-foxapi-api-key"
Then reload your shell configuration:
source ~/.zshrc  # or source ~/.bashrc
3

Modify the Base URL

Gemini CLI does not support custom base URLs through configuration. You need to modify two source files inside the installed package.First, find your npm global installation directory:
npm root -g
Then modify the following two files:File 1: {install_dir}/@google/gemini-cli/node_modules/@google/genai/dist/node/index.mjs (around line ~11222)File 2: {install_dir}/@google/gemini-cli/node_modules/@google/genai/dist/node/index.cjs (around line ~11244)In both files, find and replace:
// Before:
initHttpOptions.baseUrl = `https://generativelanguage.googleapis.com/`;

// After:
initHttpOptions.baseUrl = `https://api.foxapi.cc/`;
On macOS/Linux, you can use sed for quick replacement:
INSTALL_DIR=$(npm root -g)
sed -i.bak 's|https://generativelanguage.googleapis.com/|https://api.foxapi.cc/|g' \
  "$INSTALL_DIR/@google/gemini-cli/node_modules/@google/genai/dist/node/index.mjs" \
  "$INSTALL_DIR/@google/gemini-cli/node_modules/@google/genai/dist/node/index.cjs"
After updating Gemini CLI (npm update -g @google/gemini-cli), you will need to re-apply this modification.
4

Start Using Gemini CLI

Launch Gemini CLI in your project directory:
cd /path/to/your/project
gemini
Or run a one-off command:
gemini "Explain the structure of this project"
To switch models in interactive mode, type /model.

Verify the Connection

Run a test command to confirm everything is working:
gemini "Who are you? Please confirm you are working."
A successful response confirms that Gemini CLI is correctly routing through FoxAPI.

Available Models

ModelDescription
gemini-2.5-proMost capable Gemini model for complex tasks
gemini-2.5-flashFast and efficient for everyday coding tasks
gemini-3-pro-previewNext-gen Gemini Pro preview
gemini-3-flash-previewNext-gen Gemini Flash preview

Troubleshooting

  • Verify your FoxAPI API key is correct and starts with sk-.
  • Ensure the GEMINI_API_KEY environment variable is set properly.
  • Check that the key has sufficient balance and access to Gemini models.
  • Verify the base URL modification was applied correctly in both files (index.mjs and index.cjs).
  • Check your network connection to api.foxapi.cc.
  • Try using a VPN if your region has connectivity issues.
  • After running npm update -g @google/gemini-cli, the source files are overwritten.
  • Re-apply the base URL modification following Step 3 above.
  • Confirm the model name matches the FoxAPI model list.
  • Use /model in interactive mode to switch between available models.