Getting Started with Gemini CLI: Installation & Setup
Gemini CLI (@google/gemini-cli) is an open-source terminal AI agent that brings Google's Gemini models directly into your command-line environment. Unlike static chatbots or simple shell wrappers, Gemini CLI operates as an autonomous agent capable of inspecting file trees, editing code, running shell commands, and integrating external tools.
This guide covers the end-to-end installation, API authentication configuration, terminal environment setup, and basic interactive REPL usage for software developers.
Installing Gemini CLI & Prerequisites
Gemini CLI requires Node.js v18+ or later. You can install the CLI globally using npm or run it directly on demand using npx.
Global installation ensures the gemini command is available in all terminal sessions across macOS, Linux, and Windows WSL environments.
Quick reference
- Obtain a free or paid API key from Google AI Studio (aistudio.google.com).
- Set
GEMINI_API_KEYin your shell configuration file (~/.zshrcor~/.bashrc) for persistent session access. - Verify installation by launching
geminiin interactive REPL mode or testing a quick prompt.
Remember this
Installing Gemini CLI globally and setting GEMINI_API_KEY unlocks instant AI-assisted coding and terminal automation.
Interactive REPL Mode & Session Navigation
Running gemini without flags opens the interactive Read-Eval-Print Loop (REPL). In REPL mode, developers can engage in multi-turn conversations, ask architectural questions, request code refactoring, and execute shell commands.
The REPL supports rich terminal features including syntax highlighting, multi-line input, history search, and vim editing mode.
Quick reference
- Type standard natural language prompts to generate code, analyze stack traces, or ask documentation questions.
- Use multi-line input mode for pasting long snippets or error logs.
- Type
exitor pressCtrl+Dto terminate the interactive session cleanly.
Remember this
The Gemini CLI REPL provides an interactive conversational workbench for code generation, debugging, and terminal control.
Model Selection & Configuration Files
Gemini CLI can be configured per-project or globally via environment variables and configuration options. You can specify default models (such as gemini-1.5-pro or gemini-1.5-flash) based on whether your task requires deep reasoning or rapid generation.
For complementary terminal workflow guides, see our articles on Gemini CLI Commands and Claude Code Architecture.
Quick reference
- Use
GEMINI_MODEL=gemini-1.5-profor complex multi-file refactoring tasks requiring broad context reasoning. - Use
GEMINI_MODEL=gemini-1.5-flashfor high-speed terminal completions and single-file shell scripts. - Store project-specific CLI defaults in
.envfiles within your workspace repository.
Remember this
Configuring model selection allows developers to balance reasoning depth and response speed across different development tasks.
Key takeaway
Getting started with Gemini CLI takes only a few seconds with npm and GEMINI_API_KEY. By integrating Gemini CLI into your terminal, you gain an intelligent partner for daily coding and command-line automation.
Related Articles
Explore this topic