Google Gemini CLI Installation and Configuration Guide
This guide will help you manually install and configure Google Gemini CLI. Whether you are on macOS, Windows, or Linux, you can get started easily as long as you have a Node.js environment set up.
1. Prerequisites: Install Node.js
Gemini CLI is built on Node.js, so you need to ensure Node.js is installed on your system first.
Version requirement: Node.js v18.0.0 or higher is required.
Check Your Existing Environment
Open a terminal (Terminal or PowerShell) and run the following command to check whether Node.js is already installed:
node --versionIf the output shows a version number higher than v18, you can skip to the next step.
Install Node.js
If it is not installed, choose an installation method based on your operating system:
Recommended: install via Homebrew:
brew install nodeOr visit the Node.js official website to download the macOS installer (.pkg).
2. Install Gemini CLI
Once your environment is ready, use the npm package manager to install globally.
Run the following command in your terminal:
npm install -g @google/gemini-cliNote for macOS/Linux users:
If you encounter a permission error (EACCES), prepend sudo to the command:
sudo npm install -g @google/gemini-cli3. Configure Environment Variables
The claude-code.club AI API system supports accessing Google Gemini CLI via the GEMINI_API_KEY method. Follow the steps below to configure your environment variables.
Configuration Method: Use Gemini API Key (Recommended)
Temporary (current session only):
export GOOGLE_GEMINI_BASE_URL="https://claude-code.club/gemini"
export GEMINI_API_KEY="replace-with-your-api-key"
export GEMINI_MODEL="gemini-2.5-flash"Permanent (recommended):
For zsh (macOS default):
echo 'export GOOGLE_GEMINI_BASE_URL="https://claude-code.club/gemini"' >> ~/.zshrc
echo 'export GEMINI_API_KEY="replace-with-your-api-key"' >> ~/.zshrc
echo 'export GEMINI_MODEL="gemini-2.5-flash"' >> ~/.zshrc
source ~/.zshrcFor bash:
echo 'export GOOGLE_GEMINI_BASE_URL="https://claude-code.club/gemini"' >> ~/.bashrc
echo 'export GEMINI_API_KEY="replace-with-your-api-key"' >> ~/.bashrc
echo 'export GEMINI_MODEL="gemini-2.5-flash"' >> ~/.bashrc
source ~/.bashrcNote: After setting this, you may need to reopen your terminal window, or manually run source ~/.zshrc (zsh) / source ~/.bashrc (bash) for the configuration to take effect.
Clear Old Token Authentication Configuration
If you previously used the old token-based authentication method (CODE_ASSIST_ENDPOINT + GOOGLE_CLOUD_ACCESS_TOKEN), you need to clear those settings first, otherwise they will conflict with the new configuration.
Remove from current session:
unset CODE_ASSIST_ENDPOINT GOOGLE_CLOUD_ACCESS_TOKEN GOOGLE_GENAI_USE_GCARemove permanently:
Edit ~/.zshrc or ~/.bashrc, delete the lines containing these variables, then reload:
source ~/.zshrc # or source ~/.bashrcVerify Environment Variable Settings
After configuration, run the following command to verify that the variables are set correctly:
Bash/Zsh:
echo $GOOGLE_GEMINI_BASE_URL $GEMINI_API_KEY $GEMINI_MODELWindows PowerShell:
Write-Host $env:GOOGLE_GEMINI_BASE_URL $env:GEMINI_API_KEY $env:GEMINI_MODEL4. Verify the Installation
Once configured, let’s verify that Gemini CLI is installed correctly and working.
Check the Version
In your terminal, run:
gemini --versionIf a version number is output (e.g. 1.0.0), the tool is installed.
First Run
Type gemini to launch the tool:
geminiOn first run, you may see a welcome message or be prompted to complete a simple initialization setup.
If prompted to authenticate, select 2. Use Gemini API Key — the tool will automatically use GEMINI_API_KEY and GOOGLE_GEMINI_BASE_URL to connect to the service.
Congratulations!
You have successfully installed and configured Google Gemini CLI. You can now start experiencing the power of AI-assisted coding.
To enable Gemini 3 Pro, use the /settings command in Gemini CLI and set preview features to true.
For more information, see Gemini CLI Settings
Frequently Asked Questions
Q: Running gemini gives “command not found”?
A: Check that Node.js’s global bin directory is in your system’s PATH environment variable. Reinstalling Node.js usually resolves this issue.
Q: Getting an “Invalid API Key” error?
A: Check that your environment variables are configured correctly. In the terminal, run echo $GEMINI_API_KEY (macOS/Linux) or $env:GEMINI_API_KEY (Windows) to view the current value.
Q: How do I paste a screenshot in Gemini CLI?
A: In the Gemini CLI chat interface, macOS users can use Control + V to paste a screenshot directly, and Windows users can use Alt + V.