The Cartographer · 11 min mission

What Is Gemini CLI: Google's Open-Source Terminal Agent

Understand where Gemini CLI still fits after the individual-account transition and how its agentic loop works.

gemini-cliagentic-codinggooglefundamentalsgemini-3Fact-checked 2026-08-01
On this page

Gemini CLI is Google's open-source (Apache-2.0) AI agent for enterprise and API-key terminal workflows: you state a goal, and it runs an agent loop — calling a Gemini model, reading and editing files, running shell commands, and searching the web — pausing for your approval before changes. Individual Google AI Pro, Ultra, and free-tier accounts moved to Antigravity CLI on June 18, 2026. This guide explains the maintained Gemini CLI path and the migration boundary.

The agentic loop

The source is two packages. packages/cli is the terminal frontend you type into; packages/core is the backend that talks to the Gemini API, manages tools, and processes each request. A turn runs as a loop: core assembles context (history + tool definitions + discovered GEMINI.md files) and sends it to the model; the model replies with an answer or a tool call (read file, run command, search); core executes the tool and returns the result; the model decides the next step. This repeats until the task is done.

Two mechanisms keep the loop safe and durable. Mutating tools require confirmation — before a file write (write_file, replace) or a shell command (run_shell_command), the CLI shows the diff or exact command and waits; read-only tools (grep_search, read_file) run silently. And when a conversation nears the model's token limit, core auto-compresses history (documented as "lossless in terms of information conveyed") so long tasks do not run out of room.

one task, one loop
… scroll to run this session
Read-only tools (`grep_search`, `read_file`) run silently; the file write pauses for a y/N confirmation before applying the diff.

Install and start a session

  1. Run it without installing

    Run npx @google/gemini-cli to try it with no global install.

  2. Or install globally

    npm: npm install -g @google/gemini-cli. macOS/Linux Homebrew: brew install gemini-cli. macOS MacPorts: sudo port install gemini-cli.

  3. Launch in your project

    From the repo root, run gemini. It opens an interactive session scoped to the current directory.

  4. Or run one-shot / headless

    Non-interactive prompt: gemini -p "Explain the architecture of this codebase". Add --output-format json for structured output, or --output-format stream-json for newline-delimited JSON events. Add directories with gemini --include-directories ../lib,../docs.

Authenticating — three backends with different access

The model access, quota, and billing path come from one of three backends. Organization-managed Google sign-in uses the browser flow, an AI Studio key uses GEMINI_API_KEY, and Vertex AI combines project/location with one credential method plus a selection in /auth. The same gemini binary serves all three, but available models, limits, billing, and compliance can differ.

BackendHow you select itAvailability / best for
Google sign-in (OAuth)Browser login on first run; optional export GOOGLE_CLOUD_PROJECT="…"Code Assist Standard/Enterprise or Google Cloud accounts; individual tiers no longer served
Gemini API key (AI Studio)export GEMINI_API_KEY="…" (key from aistudio.google.com/apikey)API-key authentication remains supported; quota and billing depend on the key project
Vertex AI (Google Cloud)Set GOOGLE_CLOUD_PROJECT + GOOGLE_CLOUD_LOCATION, configure exactly one credential method, then select Vertex AI in /authEnterprise/production: higher limits, compliance
The three supported backends and the authentication route that selects each. Keep API-key and Vertex credentials isolated — see the warning below.

Models, defaults, and Auto routing

Gemini CLI defaults to Auto routing. Gemini 3 participates when it is enabled and available to the selected authentication route; the unpaid API-key tier remains Flash-only. The current recommended Pro model ID is gemini-3.1-pro-preview1,048,576 input / 65,536 output tokens, knowledge cutoff January 2025, reasoning ("Thinking") supported. You rarely need to type a model ID: use /model to inspect the available Auto and Manual choices, or launch one directly with -m, e.g. gemini -m gemini-3.1-pro-preview or gemini -m gemini-2.5-flash.

Auto routing chooses among the models your account can currently use. When a selected Pro model hits quota or availability trouble, the CLI offers a fallback rather than silently changing the session: Gemini 3 Pro can fall back to 2.5 Pro, then 2.5 Pro to 2.5 Flash. If model identity matters, inspect Manual in /model or pin a live ID with -m, and confirm the model in the session report.

Pick a model and see what routing selects

Which Claude model?

Three quick questions about your task, your tolerance for latency, and your budget — and you'll get a single model to reach for, with the reasoning behind it. All four current models are in the legend below.

0/3
Question 1 of 3

How hard is the task?

All four models

Claude Fable 5$10 / $50 per MTok

The most capable widely released model — built for the hardest reasoning and long-horizon agentic work.

Claude Opus 4.8$5 / $25 per MTok

The most capable Opus-tier model for complex reasoning and agentic coding.

Claude Sonnet 4.6$3 / $15 per MTok

The best combination of speed and intelligence — the everyday workhorse.

Claude Haiku 4.5$1 / $5 per MTok

The fastest model with near-frontier intelligence — for snappy, high-volume work.

Compare model tiers and routing outcomes. In Gemini CLI the equivalent control is `/model` → Auto (Gemini 3) or launching with `-m`.
ChannelCadenceInstall tagCurrent version
StableWeekly — Tue 20:00 UTC@latestv0.53.1
PreviewWeekly — Tue 23:59 UTC@previewCheck the current preview release
NightlyDaily — 00:00 UTC@nightlyChanges daily from main
Release channels and current stable version verified 2026-08-01 against the official release notes.

Knowledge check

You ask Gemini CLI to "refactor this module and rerun the tests." It reads several files, then pauses showing you a diff before doing anything else. Why did it stop there?

Reach the end and this star joins your charted sky.