Skip to content

Gemini CLI Installation

Google AI coding assistant setup guide.

Prerequisite

Complete Node.js installation first and make sure Node.js 18+ is installed correctly.

Gemini CLI Quick Start

Google AI coding assistant powered by Gemini 2.5 Pro.

1 Install CLI 2 Configure key 3 Start coding

Prerequisite

Before configuring Gemini CLI with CC-Switch, make sure Gemini CLI is installed globally with npm:

bash
npm install -g @google/gemini-cli

Verify installation with gemini --version.

Using CC-Switch is recommended for graphical configuration without manually creating config files.

Configuration Steps

1. Start CC-Switch and switch to the Gemini tab

  1. Open CC-Switch
  2. Click the Gemini tab
  3. Click the orange + button in the upper-right corner

2. Fill in Gemini CLI provider settings

  1. Provider name: custom name, such as Xiaomai API
  2. Base URL: https://xiaomai.win
  3. API Key: paste your Gemini-specific token from Xiaomai API
  4. Model: choose gemini-3-pro-preview or another available model
  5. Safety settings: adjust if needed
  6. Click Save

Tip

  • CC-Switch automatically creates ~/.gemini/.env and settings.json
  • You can add multiple provider configurations and switch anytime
  • Restart Gemini CLI after switching configuration

3. Enable the configuration

  1. Find the Xiaomai API configuration in the list
  2. Click Use Current
  3. The configuration is marked as current with a green label
  4. Restart Gemini CLI

4. Quick switching from the system tray

  • Right-click the CC-Switch tray icon
  • Choose the Gemini category
  • Select the target configuration
  • The configuration is applied without opening the main window

Notes

  • Create a Gemini CLI-specific token on Xiaomai API
  • Gemini tokens are not interchangeable with Claude Code or CodeX tokens
  • Restart Gemini CLI after switching configuration
  • Endpoint speed can be tested in CC-Switch

Manual Command-Line Configuration

If you do not use CC-Switch, install and configure Gemini CLI manually.

Windows

1. Install Gemini CLI Globally

powershell
npm install -g @google/gemini-cli

2. Configure Gemini CLI

Important

Replace GEMINI_API_KEY below with the Gemini CLI-specific API key you got from https://xiaomai.win.

2.1 Create the Gemini folder

Under your user directory: %USERPROFILE%\.gemini\

2.2 Create .env

Create .env in the gemini folder:

env
GOOGLE_GEMINI_BASE_URL=https://xiaomai.win
GEMINI_API_KEY=your-dedicated-key-from-https://xiaomai.win
GEMINI_MODEL=gemini-3-pro-preview

2.3 Create settings.json

Create settings.json in the gemini folder:

json
{
  "ide": {
    "enabled": true
  },
  "security": {
    "auth": {
      "selectedType": "gemini-api-key"
    }
  }
}

3. Start Gemini CLI

powershell
gemini

Ready

You can now use Agent Mode and Google Search features from Gemini CLI.

macOS

1. Install Gemini CLI Globally

bash
npm install -g @google/gemini-cli

2. Configure Gemini CLI

2.1 Create configuration directory:

bash
mkdir -p ~/.gemini
cd ~/.gemini

2.2 Create .env:

bash
cat > .env << 'EOF'
GOOGLE_GEMINI_BASE_URL=https://xiaomai.win
GEMINI_API_KEY=your-dedicated-key-from-https://xiaomai.win
GEMINI_MODEL=gemini-3-pro-preview
EOF

2.3 Create settings.json:

bash
cat > settings.json << 'EOF'
{
  "ide": {
    "enabled": true
  },
  "security": {
    "auth": {
      "selectedType": "gemini-api-key"
    }
  }
}
EOF

3. Start Gemini CLI

bash
gemini

Linux

1. Install Gemini CLI Globally

bash
sudo npm install -g @google/gemini-cli

2. Configure Gemini CLI

2.1 Create configuration directory:

bash
mkdir -p ~/.gemini
cd ~/.gemini

2.2 Create .env:

bash
cat > .env << 'EOF'
GOOGLE_GEMINI_BASE_URL=https://xiaomai.win
GEMINI_API_KEY=your-dedicated-key-from-https://xiaomai.win
GEMINI_MODEL=gemini-3-pro-preview
EOF

2.3 Create settings.json:

bash
cat > settings.json << 'EOF'
{
  "ide": {
    "enabled": true
  },
  "security": {
    "auth": {
      "selectedType": "gemini-api-key"
    }
  }
}
EOF

3. Start Gemini CLI

bash
gemini

Deployment Complete

You can now use Gemini CLI for AI-assisted coding.

FAQ

Where do I get the API key?

Sign in to the Xiaomai API platform and create a Gemini CLI-specific token.

Configuration File Locations

  • Windows: %USERPROFILE%\.gemini\
  • macOS/Linux: ~/.gemini/

More Questions

Read the FAQ or contact support.

Friendly, practical, and reliable AI coding support