AG
Gemini & Antigravity v2.0 Agentic Engineering Guide
Gemini 3 Models Quickstart Verified: 2026-10

Gemini CLI Cross-Platform Installation & Configuration (macOS / Linux / Windows)

Zero-error setup guide for the official and community Gemini CLI: macOS Homebrew, Linux one-liners, Windows Winget, and API key environment variable persistence.

Author: Google GenAI Evangelist Team • Google GenAI & Antigravity 2.0 Engineering Spec

Cross-Platform Gemini CLI Installer

scripts/install-gemini-cli.sh

#!/usr/bin/env bash
set -e

echo "==> Detecting operating system and architecture..."
OS="$(uname -s)"
ARCH="$(uname -m)"

case "$OS" in
  Darwin)
    echo "==> macOS detected. Installing via Homebrew or npm..."
    if command -v brew >/dev/null 2>&1; then
      brew install gemini-cli
    else
      npm install -g @google/gemini-cli
    fi
    ;;
  Linux)
    echo "==> Linux detected. Installing globally via npm..."
    npm install -g @google/gemini-cli
    ;;
  *)
    echo "==> Please install via Node.js npm: npm install -g @google/gemini-cli"
    exit 1
    ;;
esac

echo "==> Installation complete! Run 'gemini --version' to verify."

Why Use Gemini in Your Terminal?

Command-line interaction with Gemini 3 offers huge developer velocity gains:

  1. Pipeline Data Streams: cat build.log | gemini "Diagnose memory fault" yields instant root-cause analysis without context switching.
  2. Terminal Code Generation: Direct complex script creation into target destination files via stdout redirection.
  3. CI/CD Integration: Seamless injection of multi-modal validation or automated PR summaries into deployment pipelines.

Installation by Platform

1. macOS (Homebrew or npm)

macOS developers can install directly via Homebrew or npm:

# Recommended via Homebrew
brew install gemini-cli

# Or install globally via npm
npm install -g @google/gemini-cli

2. Linux (Ubuntu / Debian / Arch / Fedora)

Ensure Node.js 18+ is available on your machine:

# Ubuntu / Debian prerequisites
sudo apt update && sudo apt install -y nodejs npm curl

# Install Gemini CLI globally
sudo npm install -g @google/gemini-cli

# Verify version
gemini --version

3. Windows 11 / 10 (Winget or PowerShell)

Windows developers can use the Windows Package Manager:

# Install via Winget
winget install Google.GeminiCLI

# Or install via PowerShell with npm
npm install -g @google/gemini-cli

API Key Configuration

Obtain an API key from Google AI Studio and persist it in your shell environment:

macOS / Linux (zsh or bash)

# Append API key to shell configuration
echo 'export GEMINI_API_KEY="AIzaSyYourGeneratedSecretKey"' >> ~/.zshrc

# Reload active shell
source ~/.zshrc

Windows (PowerShell)

[System.Environment]::SetEnvironmentVariable('GEMINI_API_KEY', 'AIzaSyYourGeneratedSecretKey', 'User')

Quick One-Liner Verification

Test your setup immediately in your terminal:

# 1. Basic reasoning query
gemini "Summarize the CAP theorem in 2 sentences"

# 2. Pipeline log inspection
git log -n 5 --oneline | gemini "Draft concise release notes from these commits"

# 3. Specify Gemini 3 Pro
gemini --model gemini-3-pro "Write an asynchronous TCP scanner in Rust"