DEV Community

Cover image for How to Install Gemini CLI
Shashwat Pritish
Shashwat Pritish

Posted on • Edited on

How to Install Gemini CLI

This guide explains how to install and use the Gemini CLI through
Node.js.

✅ Requirements

  • Node.js 18+ installed
  • npm (comes with Node)
  • A Google AI Studio API key (Optional)

1. Install the Gemini CLI

`npm install -g @google/gemini-cli`
Enter fullscreen mode Exit fullscreen mode

This installs the global gemini command.


2. Authenticate

You can use your api key or your google account
gemini login --api-key YOUR_API_KEY

Or simply:

`gemini login`
Enter fullscreen mode Exit fullscreen mode

Then paste your API key when prompted or select login via account and login into it


3. Test if it Works

`gemini prompt "Write a short hello world message."`
Enter fullscreen mode Exit fullscreen mode

4. Use Gemini Models

Basic generation

`gemini generate --model gemini-1.5-flash --input "Explain what LLMs do."`
Enter fullscreen mode Exit fullscreen mode

Streamed output

`gemini prompt --stream "Tell me an interesting fact about space."`
Enter fullscreen mode Exit fullscreen mode

Provide a text file as input

`gemini generate --model gemini-1.5-pro --file notes.txt`
Enter fullscreen mode Exit fullscreen mode

5. Update the CLI

`npm update -g @google/generative-ai-cli`
Enter fullscreen mode Exit fullscreen mode

Top comments (0)