Login
Back to Blog
Gemini CLI ユーザーガイド - ターミナルで使う Google AI

Gemini CLI ユーザーガイド - ターミナルで使う Google AI

C
Crazyrouter Team
January 24, 2026
22 views日本語Tutorial
Share:

Gemini CLI は、Google が提供するオープンソースのコマンドライン AI ツールで、Gemini のパワーをそのままターミナルにもたらします。軽量な方法で Gemini にアクセスでき、プロンプトからモデルまでの最短経路を提供します。プロキシを設定することで、ネットワーク制限のある環境でも Gemini CLI のサービスを利用できます。

Why Choose Gemini CLI?#

  • Powerful Gemini 2.5 Pro: 100 万トークンのコンテキストウィンドウにアクセス可能
  • Built-in Tools: Google Search grounding、ファイル操作、Shell コマンド、Web スクレイピング
  • Extensible: MCP (Model Context Protocol) に対応したカスタム連携が可能
  • Terminal-First: コマンドラインで作業する開発者向けに設計
  • 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 以上
  • macOS、Linux、または Windows

Configuring the Proxy#

Set 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: これらの環境変数を .bashrc.zshrc などのシェル設定ファイルに追加しておくと、ターミナル起動時に自動的に設定されます。

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#

シンプルなテキスト応答を取得する:

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

構造化された JSON 出力を取得する:

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#

  • 大規模なコードベースの問い合わせや編集が可能
  • マルチモーダル機能を使って、PDF・画像・スケッチから新しいアプリケーションを生成
  • 自然言語を使ってデバッグやトラブルシューティングが可能

Automation and Integration#

  • プルリクエストの問い合わせや複雑な rebase 処理など、運用タスクを自動化
  • MCP servers を利用して新しい機能を接続
  • スクリプト内で非対話モードで実行し、ワークフローを自動化

Advanced Features#

  • 組み込みの Google Search を使ってリアルタイム情報を取得
  • 複雑なセッションを保存・復元できる会話チェックポイント
  • プロジェクトごとの振る舞いを調整するためのカスタムコンテキストファイル (GEMINI.md)

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#

Gemini CLI GitHub Action を使用して、Gemini CLI を GitHub のワークフローに直接統合できます:

  • Pull Request Reviews: コンテキストに基づいたフィードバックと提案による自動コードレビュー
  • Issue Triage: 内容分析に基づき、GitHub issue を自動でラベル付け・優先度付け
  • On-Demand Help: issue や pull request で @gemini-cli にメンションし、デバッグ、解説、タスク委任のサポートを依頼可能
  • Custom Workflows: チームのニーズに合わせた自動・スケジュール・オンデマンドワークフローを構築

Troubleshooting#

利用中に問題が発生した場合は、次の点を確認してください:

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#

エラーメッセージには、通常問題の原因が示されています。よくある問題:

  • 無効な API key フォーマット
  • ネットワーク接続の問題
  • プロキシ設定の誤り

4. SOCKS Proxy Format#

SOCKS プロキシを使用する場合、フォーマットが正しいことを確認してください:

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

5. Report Bugs#

組み込みコマンドで問題を報告できます:

bash
/bug

Release Versions#

Preview#

Preview 版は毎週火曜日 UTC 23:59 にリリースされます:

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

Stable#

Stable 版は毎週火曜日 UTC 20:00 にリリースされます:

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

Nightly#

Nightly 版は毎日 UTC 00:00 にリリースされます:

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

MCP Server Usage#

~/.gemini/settings.json に MCP servers を設定し、Gemini CLI をカスタムツールで拡張できます:

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#

Crazyrouter 経由で、割引価格で Gemini モデルにアクセスできます:

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

すべての価格には、公式レートと比べた 45% の割引が含まれています。


サポートが必要な場合は、サポート窓口に連絡するか、Crazyrouter documentation を参照してください。

Related Articles