Gemini CLI Installation and Configuration
Gemini CLI Installation and Configuration
Section titled “Gemini CLI Installation and Configuration”Overview of this page
💎 Gemini CLI Installation and 4All API Configuration Guide
Section titled “💎 Gemini CLI Installation and 4All API Configuration Guide”Gemini CLI is Google’s official command-line tool that lets you interact directly with the powerful Gemini models in your terminal. By following the steps below, you can quickly connect it to the 4All API aggregation platform and enjoy extremely fast AI responses.
Step 1: Install Node.js
Section titled “Step 1: Install Node.js”💡 Tip: Running Gemini CLI requires a Node.js environment. If you already have Node.js installed (for example, if you installed it while setting up Claude Code or CodeX), you can skip this step. If not, please go to the official Node.js website and download and install it.
Step 2: Install Gemini CLI
Section titled “Step 2: Install Gemini CLI”Open Command Prompt (CMD) or your terminal (PowerShell / Terminal), then run the following command to install it globally:
# Windows users should run this as Administrator# macOS/Linux users may need to add sudonpm install -g @google/gemini-cliAfter installation, you can verify it was installed successfully by running the gemini --version command.
Step 3: Configure the 4All API aggregation node
Section titled “Step 3: Configure the 4All API aggregation node”- Get an API key:
- Visit [4All API Console] https://4All API.com and sign in.
- Create a new Token and copy the generated
sk-...key for later use. (Note: if the console has groups, please choose the Gemini dedicated group to ensure the best compatibility.)
- Create the configuration file: Create a hidden folder named
.geminiin your user home directory:
- Windows:
%USERPROFILE%\.gemini(usuallyC:\Users\your-username\.gemini) - macOS/Linux:
~/.gemini
Inside that folder, create the following two files and fill in the corresponding content:
📄 File 1: .env (used to configure the base request URL and key)
GOOGLE_GEMINI_BASE_URL=https://sg.4All API.comGEMINI_API_KEY=sk-please paste the real key you obtained from 4All API hereGEMINI_MODEL=gemini-3.1-pro📄 File 2: settings.json (used to enable local IDE enhancements and secure authentication configuration)
{ "ide": { "enabled": true }, "security": { "auth": { "selectedType": "gemini-api-key" } }}⚠️ Important:
- The
GOOGLE_GEMINI_BASE_URLin the configuration file must be set exactly tohttps://sg.4All API.com, and do not add a trailing slash.
Step 4: Start and Use
Section titled “Step 4: Start and Use”Everything is ready! Open your terminal, use the cd command to navigate to your project directory, and run the following command to wake up the assistant and start interacting with Gemini 3.1 Pro:
geminiGemini CLI Windows one-click startup script this script
Section titled “Gemini CLI Windows one-click startup script this script”@echo offchcp 65001 >nulsetlocal enabledelayedexpansion
echo ========================================echo Gemini CLI - 4All API one-click setup toolecho ========================================echo.
REM Set the .gemini folder pathset "GEMINI_PATH=%USERPROFILE%\.gemini"
REM Create the .gemini folderif not exist "%GEMINI_PATH%" ( mkdir "%GEMINI_PATH%" echo [√] Folder created automatically: %GEMINI_PATH%) else ( echo [*] Folder already exists: %GEMINI_PATH%)
REM Check whether a configuration already existsif exist "%GEMINI_PATH%\.env" ( echo. echo [!] Existing .env configuration file found set /p "OVERWRITE=Overwrite and update? (Y/N): " if /i not "!OVERWRITE!"=="Y" ( echo [×] Configuration canceled pause exit /b 1 ))
REM Create the .env file(echo GOOGLE_GEMINI_BASE_URL=https://sg.4All API.comecho GEMINI_API_KEY=sk-please paste the real key you obtained from 4All API hereecho GEMINI_MODEL=gemini-2.5-pro) > "%GEMINI_PATH%\.env"echo [√] Core configuration file generated: %GEMINI_PATH%\.env
REM Create settings.json(echo {echo "ide": {echo "enabled": trueecho },echo "security": {echo "auth": {echo "selectedType": "gemini-api-key"echo }echo }echo }) > "%GEMINI_PATH%\settings.json"echo [√] IDE enhancement settings generated: %GEMINI_PATH%\settings.json
echo.echo ========================================echo 🎉 Congratulations! The basic framework for the configuration files has been set up!echo ========================================echo.echo Next steps:echo 1. Visit https://4All API.com to get your dedicated API keyecho 2. Paste the key into the newly generated .env fileecho.echo.
set /p "OPEN=Open the .env file now to fill it in? (Y/N): "if /i "!OPEN!"=="Y" ( notepad "%GEMINI_PATH%\.env")
echo.echo Press any key to exit...pause >nulThis Gemini CLI Windows one-click configuration script greatly lowers the onboarding barrier for beginners on your platform.