Skip to content

Getting Started with Gemini CLI: Installation & Setup

CoreConceptAugust 1, 20263 min read

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.

Delivery surfaces: IDE · Plugin · CLI — attachment points, not rankings
Delivery surfaces: IDE · Plugin · CLI — attachment points, not rankings

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_KEY in your shell configuration file (~/.zshrc or ~/.bashrc) for persistent session access.
  • Verify installation by launching gemini in interactive REPL mode or testing a quick prompt.
Global Installation Command
1# Install Gemini CLI globally via npm2npm install -g @google/gemini-cli3 4# Verify version and installation path5gemini --version
Authentication & API Key Setup
1# Export your Gemini API key in your shell profile (~/.zshrc or ~/.bashrc)2export GEMINI_API_KEY="AIzaSyYourSecretGeminiApiKeyHere"3 4# Launch interactive REPL mode5gemini

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 exit or press Ctrl+D to 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-pro for complex multi-file refactoring tasks requiring broad context reasoning.
  • Use GEMINI_MODEL=gemini-1.5-flash for high-speed terminal completions and single-file shell scripts.
  • Store project-specific CLI defaults in .env files 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.

Share:

Related Articles

Gemini CLI features an intuitive command syntax designed to streamline interactive terminal workflows. By mastering Slas

Read

Terminal AI agents are replacing simple code completion extensions, providing developers with autonomous command-line as

Read

Unlike basic command-line wrappers that simply send prompts to an API and print text back, Gemini CLI operates as a full

Read

Keep learning

Follow a structured path or browse all courses to go deeper.