How to Install Gemini CLI with npm and Get Started

先生

With Gemini CLI, you can easily harness the power of AI right from your terminal! This guide thoroughly explains everything from installation to initial setup.

Get Gemini CLI running in minutes—no guesswork. Install via npm, login with Google, and you’re set to access Gemini AI directly from your terminal.

✅ Prerequisites

  • Node.js v18 or newer
  • npm (bundled with Node)
  • A Google account

📥 Installation

npm install -g @google/gemini-cli

Once installation completes, confirm with:

gemini --version

🔐 First Run & Authentication

gemini

You’ll be prompted to sign in via Google. Complete the OAuth flow in your browser to authenticate.Once successful, you’ll see the Gemini prompt:

Screenshot

🚀 CLI Basics

gemini

Start a chat session and explore built-in commands like /help, /exit, /about.

Or run non-interactively with:

gemini -p "Write a Python function to reverse a string"

📚 Learn More

🧾 Why Use Gemini CLI?

  • Powerful: taps Gemini 2.5 Pro model via terminal
  • Fast setup: one command install + Google login
  • Flexible: supports interactive and script-based AI calls

Use it for code generation, testing, documentation, shell tasks—all directly from your terminal.