Skip to main content

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 AihubMax, you can use AihubMax’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

AihubMax API Key

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

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

2

Step 2: Set Your API Key

Before configuring environment variables, go to the AihubMax 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 AihubMax’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:
If you’ve cloned this docs repository, you can also run the bundled helper script to patch both files automatically:
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:
On macOS/Linux, you can use sed for quick replacement:
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:
Or run a one-off command:
To switch models in interactive mode, type /model.

Verify the Connection

Run a test command to confirm everything is working:
A successful response confirms that Gemini CLI is correctly routing through AihubMax.

Available Models

Troubleshooting

  • Verify your GEMINI_API_KEY environment variable is set correctly, with a value that is your AihubMax 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.aihubmax.com.
  • 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 AihubMax model list.
  • Use /model in interactive mode to switch between available models.