Last Updated: February 2026 | The most comprehensive Gemini CLI tutorial on the internet.
- What is Gemini CLI?
- Installation
- Configuration
- Using Third-Party Providers
- Pricing Comparison
- Tips & Tricks
- FAQ
Gemini CLI is Google's command-line AI coding assistant powered by Gemini 2.5 Pro. It features a massive 1M+ token context window, multimodal input support (images, screenshots, diagrams), and MCP server integration. It's Google's answer to Claude Code and OpenAI Codex.
- 1M+ token context window — analyze entire codebases at once
- Multimodal input — paste screenshots, diagrams, images
- MCP server support — integrate with external tools
- Free tier — generous free usage limits
- Cross-platform — works on macOS, Linux, Windows
npm install -g @google/gemini-cli
gemini --versionpip install gemini-clibrew install gemini-cligemini auth login
# Opens browser for Google account authenticationexport GEMINI_API_KEY=your-google-api-keyexport GEMINI_API_BASE=https://crazyrouter.com/v1
export GEMINI_API_KEY=sk-your-crazyrouter-keyGemini CLI supports OpenAI-compatible API providers. Use Crazyrouter to:
- Access Gemini at 55% of official pricing
- Use the same API key for Claude, GPT, and Gemini
- Get higher rate limits and auto-failover
import openai
client = openai.OpenAI(
base_url="https://crazyrouter.com/v1",
api_key="sk-your-crazyrouter-key"
)
response = client.chat.completions.create(
model="gemini-2.5-pro",
messages=[{"role": "user", "content": "Explain this codebase"}]
)
print(response.choices[0].message.content)curl https://crazyrouter.com/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"gemini-2.5-pro","messages":[{"role":"user","content":"Hello"}]}'| Model | Google Direct | Crazyrouter | Savings |
|---|---|---|---|
| Gemini 2.5 Pro | $1.25 / $10.00 | $0.69 / $5.50 | 45% |
| Gemini 2.5 Flash | $0.15 / $0.60 | $0.08 / $0.33 | 45% |
| Gemini 2.5 Flash Lite | $0.075 / $0.30 | $0.04 / $0.17 | 45% |
Prices per 1M tokens (input / output)
| Usage Level | Google Direct | Crazyrouter |
|---|---|---|
| Light (1M tokens/mo) | $10 | $5.50 |
| Medium (10M tokens/mo) | $100 | $55 |
| Heavy (50M tokens/mo) | $500 | $275 |
- Use Flash for simple tasks — 10x cheaper than Pro, fast enough for most coding tasks
- Leverage the 1M context — paste entire repos for better understanding
- Combine with CC-Switch — CC-Switch lets you switch between Gemini, Claude, and GPT with one click
| Feature | Gemini CLI | Claude Code | Codex |
|---|---|---|---|
| Context Window | 1M+ tokens | 200K | 128K |
| Free Tier | Yes | No | Limited |
| Multimodal | Yes | Yes | No |
| MCP Support | Yes | Yes | No |
| Best For | Large codebases | Refactoring | Quick edits |
Yes, there's a generous free tier. For heavier usage, use pay-as-you-go API pricing or a third-party provider like Crazyrouter for 45% savings.
Yes. Set GEMINI_API_BASE to your provider's endpoint (e.g., https://crazyrouter.com/v1).
Gemini CLI has a larger context window (1M+ vs 200K) and a free tier. Claude Code has better code refactoring. Use both through Crazyrouter with one API key.
Gemini 2.5 Pro, 2.5 Flash, 2.5 Flash Lite, and upcoming Gemini 3 models.
🔗 Links: