Login
Back to Blog
EnglishTutorial

Gemini CLI User Guide - Google AI in Your Terminal

Complete guide to install and configure Gemini CLI, Google's open-source command-line AI tool. Learn how to set up proxy, use built-in tools

C
Crazyrouter Team
January 24, 2026 / 1336 views
Share:
Gemini CLI User Guide - Google AI in Your Terminal

Gemini CLI is an open-source command-line AI tool provided by Google that brings the power of Gemini directly to your terminal. It offers a lightweight way to access Gemini, providing the most direct path from prompt to model. By configuring a proxy, you can use Gemini CLI services even in network-restricted environments.

Why Choose Gemini CLI?#

  • Powerful Gemini 2.5 Pro: Access to 1 million token context window
  • Built-in Tools: Google Search grounding, file operations, Shell commands, web scraping
  • Extensible: Supports MCP (Model Context Protocol) for custom integrations
  • Terminal-First: Designed for developers who work in the command line
  • Open Source: Apache 2.0 License

Installation#

Quick Install#

Run Instantly with npx (No Installation Required)#

bash
# Use official repository
npx https://github.com/google-gemini/gemini-cli

Global Installation with npm#

bash
npm install -g @google/gemini-cli

Install with Homebrew (macOS/Linux)#

bash
brew install gemini-cli

System Requirements#

  • Node.js version 20 or higher
  • macOS, Linux, or Windows

Configuring the Proxy#

Set Environment Variables#

Before using the proxy, configure the following environment variables:

Linux / macOS#

bash
# Set API Key
export GEMINI_API_KEY=sk-your-api-key-here

# Set API Proxy URL
export GOOGLE_GEMINI_BASE_URL=https://crazyrouter.com/

Windows CMD#

cmd
set GEMINI_API_KEY=sk-your-api-key-here
set GOOGLE_GEMINI_BASE_URL=https://crazyrouter.com/

Windows PowerShell#

powershell
$env:GEMINI_API_KEY = "sk-your-api-key-here"
$env:GOOGLE_GEMINI_BASE_URL = "https://crazyrouter.com/"

Tip: Add these environment variables to your .bashrc, .zshrc, or shell configuration file so they are automatically set each time you start the terminal.

Quick Start#

Basic Usage#

Start in Current Directory#

bash
gemini

Include Multiple Directories#

bash
gemini --include-directories ../lib,../docs

Use a Specific Model#

bash
gemini -m gemini-2.5-flash

Non-Interactive Script Mode#

Get a simple text response:

bash
gemini -p "Explain the architecture of this codebase"

Get structured JSON output:

bash
gemini -p "Explain the architecture of this codebase" --output-format json

Quick Examples#

Start a New Project#

bash
cd new-project/
gemini
> Write me a Discord bot that answers questions using the FAQ.md file I provided

Analyze Existing Code#

bash
git clone https://github.com/google-gemini/gemini-cli
cd gemini-cli
gemini
> Give me a summary of all changes from yesterday

Main Features#

Code Understanding and Generation#

  • Query and edit large codebases
  • Generate new applications from PDFs, images, or sketches using multimodal capabilities
  • Debug issues and troubleshoot using natural language

Automation and Integration#

  • Automate operational tasks like querying pull requests or handling complex rebases
  • Connect new capabilities using MCP servers
  • Run non-interactively in scripts for workflow automation

Advanced Features#

  • Get real-time information using built-in Google Search
  • Conversation checkpoints to save and restore complex sessions
  • Custom context files (GEMINI.md) to tailor behavior for your project

Common Commands and Examples#

Explore Codebase#

code
> Describe the main components of this system architecture
> What security mechanisms are in place?
> Provide a step-by-step onboarding document for new developers

Work with Existing Code#

code
> Implement a first draft for GitHub issue #123
> Help me migrate this codebase to the latest version of Java. Start with a plan

Automate Workflows#

code
> Create a slideshow showing the git history from the past 7 days, grouped by feature and team member
> Create a full-screen web app for wall display showing our most interactive GitHub issues

System Interaction#

code
> Convert all images in this directory to png and rename them using the date from exif data
> Organize my PDF invoices by spending month

GitHub Integration#

Use the Gemini CLI GitHub Action to integrate Gemini CLI directly into your GitHub workflows:

  • Pull Request Reviews: Automated code reviews with contextual feedback and suggestions
  • Issue Triage: Automatically label and prioritize GitHub issues based on content analysis
  • On-Demand Help: Mention @gemini-cli in issues and pull requests for help with debugging, explanations, or task delegation
  • Custom Workflows: Build automated, scheduled, and on-demand workflows tailored to your team's needs

Troubleshooting#

If you encounter issues during use, consider the following:

1. Check Environment Variables#

bash
echo $GEMINI_API_KEY
echo $GOOGLE_GEMINI_BASE_URL

2. Check Network Connection#

bash
curl -I https://crazyrouter.com/

3. Check Error Messages#

Error messages usually indicate the problem. Common issues include:

  • Invalid API key format
  • Network connectivity issues
  • Incorrect proxy configuration

4. SOCKS Proxy Format#

If using SOCKS proxy, ensure the format is correct:

code
socks5://<user>:<pass>@<proxy>:<port>

5. Report Bugs#

Use the built-in command to report issues:

bash
/bug

Release Versions#

Preview#

New preview versions are released every Tuesday at UTC 23:59:

bash
npm install -g @google/gemini-cli@preview

Stable#

New stable versions are released every Tuesday at UTC 20:00:

bash
npm install -g @google/gemini-cli@latest

Nightly#

Nightly versions are released every day at UTC 00:00:

bash
npm install -g @google/gemini-cli@nightly

MCP Server Usage#

Configure MCP servers in ~/.gemini/settings.json to extend Gemini CLI with custom tools:

text
> @github list my open pull requests
> @slack send a summary of today's commits to #dev channel
> @database run a query to find inactive users

Pricing via Crazyrouter#

Access Gemini models at discounted rates:

ModelInput PriceOutput Price
gemini-2.5-pro$0.625/1M tokens$2.50/1M tokens
gemini-2.5-flash$0.038/1M tokens$0.15/1M tokens
gemini-2.5-flash-lite$0.019/1M tokens$0.075/1M tokens

All prices include a 45% discount compared to official rates.


Need help? Contact support or check the Crazyrouter documentation for more information.

Implementation Guides

Related Posts

Crazyrouter Codex CLI: Use Codex with One API Key and an OpenAI-Compatible GatewayTutorial

Crazyrouter Codex CLI: Use Codex with One API Key and an OpenAI-Compatible Gateway

Set up OpenAI Codex CLI through Crazyrouter with one command on Windows, macOS, and Linux. Use an OpenAI-compatible base URL, one API key, and model routing for GPT, Claude, Gemini, DeepSeek, and Qwen-style workflows.

Jun 4
Midjourney API Without Discord: How to Generate AI Images ProgrammaticallyTutorial

Midjourney API Without Discord: How to Generate AI Images Programmatically

"Learn how to use Midjourney's image generation through an API without Discord. Complete guide with Python code examples, pricing, and alternatives."

Feb 21
/v1/chat/completions vs /v1/responses vs /v1/messages: Which AI API Endpoint Should You Use?Tutorial

/v1/chat/completions vs /v1/responses vs /v1/messages: Which AI API Endpoint Should You Use?

A practical guide to choosing the correct AI API endpoint. Learn the differences between OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages to avoid model unavailable errors caused by wrong endpoint routing.

Jun 4
AI Image API Playground: Test GPT Image, Imagen, Qwen Image and FLUX OnlineTutorial

AI Image API Playground: Test GPT Image, Imagen, Qwen Image and FLUX Online

A practical guide for developers who need to compare AI image generation models before building production code. Learn how to test GPT Image, Imagen, Qwen Image, FLUX, and DALL-E style workflows from one playground and one API key.

Jun 4
Claude Code Installation and Usage Guide - AI Programming Assistant SetupTutorial

Claude Code Installation and Usage Guide - AI Programming Assistant Setup

Complete guide to install and configure Claude Code, the AI programming assistant. Learn how to set up Node.js, configure API tokens, and start coding with AI in your terminal.

Jan 24
Claude API Key: Complete Setup, Security, and Troubleshooting GuideTutorial

Claude API Key: Complete Setup, Security, and Troubleshooting Guide

One wrong header format can turn every Claude request into a 401 “Invalid API key” error in seconds. Most teams assume **claude api key** issues start at the model layer, but the real breakpoints u...

Mar 18