Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.foxapi.cc/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Gemini CLI is Google’s open-source command-line AI tool that lets you interact with Gemini models directly from the terminal for code understanding, generation, and editing. By connecting Gemini CLI to FoxAPI, you can use FoxAPI’s Gemini model offerings.
Gemini CLI does not support custom base URLs through configuration files. Configuration requires modifying source files inside the installed package. This modification needs to be reapplied after package updates.

Prerequisites

FoxAPI API Key

An active FoxAPI API key with access to Gemini models. Go to FoxAPI →

Node.js 20+

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

Installation & Configuration

1

Step 1: Install Gemini CLI

npm install -g @google/gemini-cli
2

Step 2: Set Your API Key

Before configuring environment variables, go to the FoxAPI Console to create a dedicated key:
  1. Open the “API Keys” page and click “Create Key”.
  2. Name the key “Gemini CLI” or another easily identifiable name.
  3. Make sure to select the “Gemini_CLI” group — this group enables the additional transcoding and rate limits required by the Gemini protocol.
If you don’t select the “Gemini_CLI” group, Gemini CLI may not be able to call FoxAPI’s Gemini models properly, or you may encounter 403/429 errors.
After generating the key, set it as the GEMINI_API_KEY environment variable. Choose either method below: use CC-Switch for automatic injection, or manually export the variable in your shell profile.
3

Step 3: Modify the Base URL

CC-Switch only injects GEMINI_API_KEY — it does not modify the Base URL configuration inside the CLI installation directory. Regardless of which method you chose in the previous step, the following modification must be performed once.
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
If you’ve cloned this docs repository, you can also run the bundled helper script to patch both files automatically:
bash 101.api_docs/mintlify/ai-tools/patch-gemini-cli-base-url.sh
The script resolves the global install directory, patches both index.mjs and index.cjs, and creates .foxapi.bak backups of the original files.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), the source files will be overwritten. You will need to re-apply this modification.
4

Step 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 "Hello, please confirm you are working properly."
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 GEMINI_API_KEY environment variable is set correctly, with a value that is your FoxAPI API Key (starts with sk-).
  • Ensure the key has not expired and has sufficient balance.
  • Verify the key has 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.