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
Configure Quickly with CC-Switch (Recommended)
Prerequisite
Before configuring Gemini CLI with CC-Switch, make sure Gemini CLI is installed globally with npm:
npm install -g @google/gemini-cliVerify 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
- Open CC-Switch
- Click the Gemini tab
- Click the orange + button in the upper-right corner
2. Fill in Gemini CLI provider settings
- Provider name: custom name, such as
Xiaomai API - Base URL:
https://xiaomai.win - API Key: paste your Gemini-specific token from Xiaomai API
- Model: choose
gemini-3-pro-previewor another available model - Safety settings: adjust if needed
- Click Save
Tip
- CC-Switch automatically creates
~/.gemini/.envandsettings.json - You can add multiple provider configurations and switch anytime
- Restart Gemini CLI after switching configuration
3. Enable the configuration
- Find the Xiaomai API configuration in the list
- Click Use Current
- The configuration is marked as current with a green label
- 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
npm install -g @google/gemini-cli2. 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:
GOOGLE_GEMINI_BASE_URL=https://xiaomai.win
GEMINI_API_KEY=your-dedicated-key-from-https://xiaomai.win
GEMINI_MODEL=gemini-3-pro-preview2.3 Create settings.json
Create settings.json in the gemini folder:
{
"ide": {
"enabled": true
},
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
}
}3. Start Gemini CLI
geminiReady
You can now use Agent Mode and Google Search features from Gemini CLI.
macOS
1. Install Gemini CLI Globally
npm install -g @google/gemini-cli2. Configure Gemini CLI
2.1 Create configuration directory:
mkdir -p ~/.gemini
cd ~/.gemini2.2 Create .env:
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
EOF2.3 Create settings.json:
cat > settings.json << 'EOF'
{
"ide": {
"enabled": true
},
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
}
}
EOF3. Start Gemini CLI
geminiLinux
1. Install Gemini CLI Globally
sudo npm install -g @google/gemini-cli2. Configure Gemini CLI
2.1 Create configuration directory:
mkdir -p ~/.gemini
cd ~/.gemini2.2 Create .env:
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
EOF2.3 Create settings.json:
cat > settings.json << 'EOF'
{
"ide": {
"enabled": true
},
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
}
}
EOF3. Start Gemini CLI
geminiDeployment 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/