Skip to content

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.

💡 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.

Open Command Prompt (CMD) or your terminal (PowerShell / Terminal), then run the following command to install it globally:

Terminal window
# Windows users should run this as Administrator
# macOS/Linux users may need to add sudo
npm install -g @google/gemini-cli

After 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”
  1. 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.)
  1. Create the configuration file: Create a hidden folder named .gemini in your user home directory:
  • Windows: %USERPROFILE%\.gemini (usually C:\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.com
GEMINI_API_KEY=sk-please paste the real key you obtained from 4All API here
GEMINI_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_URL in the configuration file must be set exactly to https://sg.4All API.com, and do not add a trailing slash.

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:

Terminal window
gemini

Gemini CLI Windows one-click startup script this script

Section titled “Gemini CLI Windows one-click startup script this script”
Terminal window
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
echo ========================================
echo Gemini CLI - 4All API one-click setup tool
echo ========================================
echo.
REM Set the .gemini folder path
set "GEMINI_PATH=%USERPROFILE%\.gemini"
REM Create the .gemini folder
if 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 exists
if 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.com
echo GEMINI_API_KEY=sk-please paste the real key you obtained from 4All API here
echo 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": true
echo },
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 key
echo 2. Paste the key into the newly generated .env file
echo.
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 >nul

This Gemini CLI Windows one-click configuration script greatly lowers the onboarding barrier for beginners on your platform.