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/generative-ai-cli`
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`
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."`
4. Use Gemini Models
Basic generation
`gemini generate --model gemini-1.5-flash --input "Explain what LLMs do."`
Streamed output
`gemini prompt --stream "Tell me an interesting fact about space."`
Provide a text file as input
`gemini generate --model gemini-1.5-pro --file notes.txt`
5. Update the CLI
`npm update -g @google/generative-ai-cli`
Top comments (0)