Your complete, step-by-step guide to getting Google's powerful Gemini CLI up and running on your machine — for free. From prerequisites to your first AI-powered command, we've got every step covered.
Gemini CLI brings Google's Gemini AI model directly into your command-line environment. Interact with powerful AI — ask questions, generate code, analyse files — without ever leaving your terminal.
It's open-source, free to use with a Google account, and runs on macOS, Windows, and Linux.
Before installing Gemini CLI, make sure your system meets these requirements. The setup is lightweight — you likely already have most of these in place.
Version 18 or higher required. Node.js powers the CLI runtime.
Comes bundled with Node.js. Used to run and install the CLI package.
A free Google account is all you need to authenticate and access Gemini.
Required for authentication and sending prompts to the Gemini API.
Open your terminal and verify that Node.js version 18 or higher is installed. This is the single most important prerequisite before proceeding.
node --version
# Expected output: v18.0.0 or higher
# e.g. v20.11.0Go to https://nodejs.org and download the LTS (Long Term Support) version — this is the recommended stable release for most users.
Launch the downloaded installer and follow the on-screen prompts. Accept the default settings — they're suitable for most use cases.
Close and reopen your terminal, then run node --version and npm --version to confirm both are installed correctly.
The fastest way to launch Gemini CLI is using npx — no global install required. This runs the latest version of the CLI directly without permanently installing it on your machine.
npx https://github.com/google-gemini/gemini-cliOn first run, npx will download the necessary packages automatically. You'll see a brief download progress bar, after which the CLI will launch.
If you plan to use Gemini CLI regularly, installing it globally means you can launch it from anywhere with a single command. This is ideal for developers who want seamless day-to-day access.
npm install -g @google/gemini-cliAfter installation completes, verify the global install was successful:
gemini --versionnpm update -gWhen you launch Gemini CLI for the first time, it will prompt you to authenticate. This links the CLI to your free Google account and grants access to the Gemini API via the free tier.
The CLI will open a browser window automatically. Simply sign in with your existing Google account — no billing information or credit card is required for the free tier.
The entire authentication process takes under 60 seconds. Once authorised, your credentials are cached locally so you won't need to sign in again on future sessions.
When Gemini CLI first launches, it will ask you to choose how you'd like to authenticate. There are two supported options:
The simplest option. Uses your Google account via OAuth. No API key needed. Perfect for individual users on the free tier. Select this option and follow the browser prompts.
For advanced users or CI/CD pipelines. Generate a free Gemini API key from Google AI Studio at aistudio.google.com, then paste it when prompted in the terminal.
Visit aistudio.google.com and sign in with your Google account.
In the left sidebar, click Get API Key, then Create API Key.
Copy the generated key and store it safely — you won't be able to view it again.
When the CLI prompts for an API key, paste your key and press Enter.
Gemini CLI's free tier is surprisingly generous. Here's what you get with a standard Google account — no payment required.
Up to 1 million tokens per minute on the free tier with Gemini 1.5 Pro.
1,500 free API requests per day — more than enough for most developers.
Zero cost. No credit card. No billing setup required to use the free tier.
Once authenticated, you're ready to start using Gemini CLI. Launch it with one of the following commands depending on how you installed it:
# If using npx:
npx https://github.com/google-gemini/gemini-cli
# If installed globally:
geminiThe CLI will load and display a welcome prompt. You're now inside an interactive session with Gemini — type any question or command to begin.
Not sure where to start? Here are some great first prompts to explore the power of Gemini CLI right away.
What are the benefits of using TypeScript over JavaScript?Write a Python function that reverses a linked listSummarise the contents of README.mdExplain this error: TypeError: Cannot read properties of undefinedGemini CLI features an intuitive interactive interface. Once inside a session, you can type prompts naturally — just as you would in a chat. The CLI supports multi-line input, file references, and special slash commands.
/help — View all available commands/clear — Clear the current conversation/quit or /exit — Exit the CLI/model — Switch between Gemini modelsGemini CLI isn't limited to interactive mode. You can pass prompts directly as command-line arguments — perfect for scripting, automation, and one-off queries without entering an interactive session.
# One-shot prompt:
gemini "Explain the difference between REST and GraphQL"
# Pipe file contents into Gemini:
cat server.js | gemini "Review this code for bugs"
# Summarise a file:
gemini -p "Summarise this document" < report.txtIf you're using an API key instead of Google login, it's best practice to store it as an environment variable rather than pasting it each session. This keeps your key secure and makes it available automatically.
# macOS / Linux — add to ~/.bashrc or ~/.zshrc:
export GEMINI_API_KEY="your-api-key-here"
# Windows (Command Prompt):
setx GEMINI_API_KEY "your-api-key-here"
# Windows (PowerShell):
$env:GEMINI_API_KEY = "your-api-key-here"Keeping Gemini CLI up to date ensures you have the latest features, bug fixes, and model improvements. Here's how to update depending on your installation method.
No action needed! npx always fetches the latest version automatically each time you run it.
npx https://github.com/google-gemini/gemini-cliRun the update command to pull the latest version to your global npm registry.
npm update -g @google/gemini-cliVerify which version you're currently running at any time.
gemini --versionRunning into issues? Here are the most common problems users encounter during setup, and how to resolve them quickly.
Node.js is not installed or not on your PATH. Download it from nodejs.org and reinstall, or add Node to your system PATH manually.
On macOS/Linux, prefix with sudo: sudo npm install -g @google/gemini-cli. Alternatively, configure npm to use a local directory.
Try running gemini auth logout then gemini auth login again. Ensure pop-ups are not blocked in your browser.
Double-check that your key was copied correctly with no extra spaces. Regenerate a new key from Google AI Studio if needed.
You've hit the free tier limit. Wait a few minutes before retrying, or space out your requests. The limit resets every minute (requests per minute) and daily (requests per day).
Check your internet connection. Long or complex prompts may take more time — try breaking them into smaller, more focused requests if the timeout persists.
If you're on a corporate network, the Gemini API endpoint may be blocked. Configure your npm proxy settings or contact your network administrator.
Use Terminal or iTerm2. Node.js is best installed via Homebrew: brew install node. Works seamlessly on both Intel and Apple Silicon (M1/M2/M3).
Use PowerShell or Windows Terminal. Download Node.js from nodejs.org. For the best experience, consider using WSL2 (Windows Subsystem for Linux).
Install Node.js via your package manager: sudo apt install nodejs npm on Ubuntu/Debian, or sudo dnf install nodejs on Fedora. Use nvm for version management.
Gemini CLI supports agentic mode — where Gemini can autonomously execute multi-step tasks on your behalf, including reading files, running shell commands, and iterating on code.
Agentic tasks are triggered naturally through your prompts. For example:
gemini "Audit my project directory for security vulnerabilities and suggest fixes"
gemini "Refactor all .js files in /src to use async/await instead of callbacks"Wondering how Gemini CLI stacks up against the competition? Here's a quick comparison of the most popular AI command-line tools available today.
Congratulations — you've successfully installed and configured Gemini CLI! You now have access to one of the most capable AI models available, right from your terminal.
Explore the full docs at github.com/google-gemini/gemini-cli for advanced configuration and features.
Visit aistudio.google.com to manage your API keys, view usage, and explore Gemini models.
Join the discussion on GitHub Issues and the Google AI Developer Forum to get help and share tips.
Install Gemini CLI — Free Version