惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 【当耐特】
M
MIT News - Artificial intelligence
月光博客
月光博客
博客园_首页
博客园 - 叶小钗
T
Tailwind CSS Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
InfoQ
量子位
小众软件
小众软件
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
IT之家
IT之家
Jina AI
Jina AI
阮一峰的网络日志
阮一峰的网络日志
G
Google Developers Blog
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报

Crazyrouter Blog

Gemini CLI Complete Guide 2026: Repo Automation, CI Agents, and Multi-Model Routing Ideogram AI Guide 2026: Brand Design Automation, API Workflows, and Alternatives GLM 4.6 API Guide 2026: Agents, RAG, Tool Calling, and Bilingual Apps WAN 2.2 Animate Tutorial 2026: Character Consistency, Shot Control, and API Workflows Google Veo3 API Guide 2026: Production Video Pipelines, Prompts, Pricing, and Fallbacks AI API Pricing Comparison 2026: Text, Image, Video, Caching, and Router Costs Codex CLI Installation Guide 2026: Windows, macOS, Linux, Proxies, and CI Setup How to Get a Claude API Key in 2026: Secure Setup for Teams, CI, and Alternatives Gemini Advanced Review 2026: Is It Worth It for Coding, Research, and API Teams? Claude Code Pricing Guide 2026: Team Agent Budgets, API Fallbacks, and Cost Control Seedance 2.0 Pricing: Convert 46 CNY per Million Tokens to Cost per Second Seedance 2.0 计费详解:46元/百万Token换算成每秒多少钱 Seedance 2.0料金解説:100万Tokenあたり46元を1秒あたりコストに換算 Gemini CLI 使用教程 2026:安装、代码示例、代理环境与 API 接入 Gemini 是什么?2026 完整介绍、API 使用教程与价格对比 Qwen2.5-Omni Guide 2026: Real-Time Voice, Vision, and Multimodal Agents Kimi K2 Thinking Guide 2026: Reasoning Workflows, Evals, and Cost Control Google Veo3 API Guide 2026: Batch Video Pipelines, Pricing, and Fallbacks Codex CLI Installation Guide 2026: macOS, Linux, WSL, Proxies, and Dev Containers How to Get a Claude API Key in 2026: Safe Production Setup and Alternatives AI API Pricing Comparison 2026: GPT, Claude, Gemini, Video, and Agent Workloads Gemini Advanced Review 2026: Is It Worth It for Developer Teams? Claude Code Pricing Guide 2026: API Fallbacks, Team Seats, and Budget Control Seedream 4.0 API Tutorial 2026: Batch Image Generation, Product Creative, and Pricing Qwen2.5-Omni Guide 2026: Real-Time Voice, Vision, Text Agents, and API Integration Kimi K2 Thinking Guide 2026: Reasoning Agents, Evaluation Workflows, and API Cost Control WAN 2.2 Animate Tutorial 2026: Character Motion, Shot Control, API Pipelines, and Pricing Google Veo3 API Guide 2026: Production Video Workflows, Prompts, Pricing, and Fallbacks AI API Pricing Comparison 2026: OpenAI, Claude, Gemini, DeepSeek, and Router Costs How to Get a Claude API Key in 2026: Setup, Security, Rotation, and Alternatives
Gemini CLI 使用教程:开发者终端 AI 助手完全指南
Crazyrouter Team · 2026-05-05 · via Crazyrouter Blog

Gemini CLI 使用教程:开发者终端 AI 助手完全指南#

Gemini CLI 是 Google 推出的终端 AI 编程助手,让开发者直接在命令行中使用 Gemini 2.5 Pro 的强大能力。类似于 Claude Code 和 OpenAI Codex CLI,Gemini CLI 可以读取文件、编写代码、执行命令,并管理整个开发工作流。

本教程覆盖从零开始的完整使用流程,适合想要在终端中集成 AI 能力的开发者。

什么是 Gemini CLI?#

Gemini CLI 是一个开源的命令行工具,由 Google 官方维护。核心特性:

  • 免费使用 — 通过 Google AI Studio API key 即可使用,有免费额度
  • Gemini 2.5 Pro — 使用 Google 最强模型,128K 上下文
  • 文件系统访问 — 读取、创建、修改项目文件
  • 命令执行 — 在终端中运行构建、测试等命令
  • 多模态 — 支持图片、PDF 等文件分析
  • 开源 — 代码完全开源,可自定义扩展

安装与配置#

系统要求#

  • Node.js 18+
  • npm 或 yarn
  • macOS、Linux 或 Windows (WSL)

安装步骤#

配置 API Key#

获取免费 API Key#

  1. 访问 Google AI Studio
  2. 登录 Google 账号
  3. 点击 "Get API Key" → "Create API Key"
  4. 复制 key 并设置环境变量

免费额度: Google AI Studio 提供每分钟 2 次请求、每天 50 次请求的免费额度。对于个人开发足够使用。

基础用法#

启动交互模式#

常用命令#

单次执行模式#

高级用法#

项目上下文配置#

在项目根目录创建 .gemini/config.json

自定义系统提示#

多文件操作#

与 Git 集成#

调试工作流#

实用工作流示例#

新功能开发#

API 开发#

数据库迁移#

成本优化#

免费使用策略#

方案每日限制适合场景
Google AI Studio 免费50 次/天个人学习、轻度使用
Crazyrouter按量付费,无限制专业开发、团队使用
自建代理取决于配额企业内部

通过 Crazyrouter 降低成本#

Gemini CLI vs Claude Code vs Codex CLI#

特性Gemini CLIClaude CodeCodex CLI
价格免费额度 + 按量$20-200/月$200/月 (Pro)
模型Gemini 2.5 ProOpus 4 / Sonnet 4o4-mini
上下文1M tokens200K tokens128K tokens
开源
文件操作
命令执行
多模态
中文支持优秀良好一般

常见问题#

Gemini CLI 免费吗?#

是的。通过 Google AI Studio API key 可以免费使用,每天 50 次请求。超出免费额度后按量计费,或通过 Crazyrouter 以更低价格使用。

Gemini CLI 支持中文吗?#

完全支持。Gemini 2.5 Pro 的中文能力很强,可以用中文提问、生成中文代码注释、编写中文文档。

Gemini CLI 和 ChatGPT 有什么区别?#

Gemini CLI 是终端工具,直接操作你的代码文件和运行命令。ChatGPT 是网页聊天界面,无法直接访问你的项目。Gemini CLI 更适合实际编程工作。

如何在中国使用 Gemini CLI?#

Google AI Studio 在中国可能需要代理访问。推荐通过 Crazyrouter 使用,无需代理,直接设置 GEMINI_BASE_URL 即可。

Gemini CLI 安全吗?#

Gemini CLI 是开源项目,代码可审计。它只在你明确允许时才执行命令和修改文件。敏感操作(如 git push)可以配置为需要确认。

总结#

Gemini CLI 是 2026 年最具性价比的终端 AI 编程助手 — 免费额度慷慨,模型能力强大,开源可定制。对于中文开发者来说,它的中文支持和 1M token 上下文窗口是独特优势。

通过 Crazyrouter 使用 Gemini CLI,可以获得更稳定的访问和 60% 的成本节省,特别适合需要大量使用的专业开发团队。