Install and configure Gemini CLI on your computer using environment variables.Windows#
1. Install Node.js#
Go to the Node.js official website, then download and install the LTS version. If Node.js is already installed, you can skip this step.If a version number is displayed, Node.js has been installed successfully.Please note that the Node.js version must be 18 or later.If your version is lower than this, you can ask an AI assistant how to upgrade Node.js. Ask it to give you commands for collecting system information first, and then it can provide the fastest and most accurate guidance.
2. Install Gemini CLI#
Open PowerShell. We recommend running it as administrator. Then run:If you see an error saying that scripts are disabled on this system, run PowerShell as administrator, then execute:Set-ExecutionPolicy Unrestricted
3. Create Configuration Files#
Open PowerShell. We recommend running it as administrator. Then run:
mkdir "$env:USERPROFILE\.gemini" -Force | Out-Null
$envText = @'
GEMINI_API_KEY=replace_with_your_API_KEY_here
GOOGLE_GEMINI_BASE_URL=https://api.moteapi.com/gemini_cli
GEMINI_MODEL=gemini-3-pro
'@
[System.IO.File]::WriteAllText("$env:USERPROFILE\.gemini\.env", $envText, (New-Object System.Text.UTF8Encoding($false)))
$json = @'
{
"ide": {
"enabled": true
},
"security": {
"auth": {
"selectedType": "gemini-api-key"
}
}
}
'@
[System.IO.File]::WriteAllText("$env:USERPROFILE\.gemini\settings.json", $json, (New-Object System.Text.UTF8Encoding($false)))
Verify that the configuration was created successfully:Get-Content "$env:USERPROFILE\.gemini\.env"
Get-Content "$env:USERPROFILE\.gemini\settings.json"
4. Verify the Configuration#
Enter gemini in Terminal to start Gemini, then type the following in the dialog:Say hello to it. If Gemini replies normally and you can see the request record on the platform, the configuration was successful.macOS#
1. Install Node.js#
First, make sure Homebrew is installed on your computer. If it is not installed, open the Homebrew website and copy the one-line installation command from the page.Some resources required during Homebrew installation are hosted overseas, so you may need to enable a TUN proxy.After Homebrew is installed, use it to install Node.js. If Node.js is already installed, you can skip this step.Use the following command to verify the installation:Please note that the Node.js version must be 18 or later.If your version is lower than this, you can ask an AI assistant how to upgrade Node.js. Ask it to give you commands for collecting system information first, and then it can provide the fastest and most accurate guidance.
2. Install Gemini CLI#
3. Create Configuration Files#
Verify that the configuration was created successfully:4. Verify the Configuration#
Enter gemini in Terminal to start Gemini, then type the following in the dialog:Say hello to it. If Gemini replies normally and you can see the request record on the platform, the configuration was successful.Linux#
1. Install Node.js#
Use the following commands to install Node.js. If Node.js is already installed, you can skip this step.Please note that the Node.js version must be 18 or later.If your version is lower than this, you can ask an AI assistant how to upgrade Node.js. Ask it to give you commands for collecting system information first, and then it can provide the fastest and most accurate guidance.
2. Install Gemini CLI#
If the output looks like the screenshot below, the installation was successful.3. Create Configuration Files#
Verify that the configuration was created successfully:4. Verify the Configuration#
Enter gemini in Terminal to start Gemini, then type the following in the dialog:Say hello to it. If Gemini replies normally and you can see the request record on the platform, the configuration was successful.