Gemini モデル選択ガイド — タスク別に最適なモデルを選ぶ方法
Gemini のモデルラインアップは多様で、各モデルは異なるユースケースに最適化されています。このガイドでは、コスト・速度・品質の観点からモデル選択の指針を提供します。
Gemini モデルラインアップ概要
現在利用可能な主要な Gemini モデルは以下の通りです:
| モデル | 発表 | 用途 | コンテキストウィンドウ | |--------|------|------|----------------------| | Gemini 2.5 Pro | 2024年12月 | 複雑な推論・コーディング・マルチモーダル | 1,000,000 トークン | | Gemini 2.5 Flash | 2024年12月 | バランス型・チャット・要約 | 1,000,000 トークン | | Gemini 2.5 Flash Lite | 2025年3月 | リアルタイム・高速応答 | 100,000 トークン | | Gemini 3 Pro | 2025年2月 | 最新の推論能力・複雑なタスク | 2,000,000 トークン | | Gemini 3 Flash | 2025年2月 | 次世代バランス型 | 500,000 トークン |
詳細な比較表
パフォーマンス指標
| 指標 | 2.5 Pro | 2.5 Flash | 2.5 FL | 3 Pro | 3 Flash | |------|---------|-----------|--------|-------|---------| | 推論品質 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | | 応答速度 | 中 | 高速 | 非常に高速 | 遅い | 高速 | | コスト効率 | 低 | 中 | 高 | 最低 | 中 | | マルチモーダル対応 | 優秀 | 優秀 | 基本 | 優秀 | 優秀 | | コンテキストウィンドウ | 1M | 1M | 100K | 2M | 500K |
API 料金比較(2026年3月時点)
# 入力・出力トークン単価の計算例
pricing = {
"gemini-2.5-pro": {
"input": 0.30, # $0.30 / 百万トークン
"output": 1.20 # $1.20 / 百万トークン
},
"gemini-2.5-flash": {
"input": 0.10,
"output": 0.40
},
"gemini-2.5-flash-lite": {
"input": 0.04,
"output": 0.12
},
"gemini-3-pro": {
"input": 0.50,
"output": 2.00
},
"gemini-3-flash": {
"input": 0.15,
"output": 0.60
}
}
def estimate_cost(model_name, input_tokens, output_tokens):
"""API 利用コストを推定"""
rates = pricing.get(model_name, {})
input_cost = (input_tokens / 1_000_000) * rates["input"]
output_cost = (output_tokens / 1_000_000) * rates["output"]
return input_cost + output_cost
# 例:100万入力トークン、20万出力トークン
cost_pro = estimate_cost("gemini-2.5-pro", 1_000_000, 200_000)
cost_flash = estimate_cost("gemini-2.5-flash", 1_000_000, 200_000)
cost_lite = estimate_cost("gemini-2.5-flash-lite", 1_000_000, 200_000)
print(f"2.5 Pro コスト: ${cost_pro:.2f}")
print(f"2.5 Flash コスト: ${cost_flash:.2f}")
print(f"2.5 Flash Lite コスト: ${cost_lite:.2f}")タスク別モデル選択ガイド
1. コーディング・ソフトウェア開発
推奨モデル: Gemini 2.5 Pro → 3 Pro
from anthropic import Anthropic
client = Anthropic()
# 複雑なコーディングタスクは Pro を使用
response = client.messages.create(
model="gemini-2.5-pro",
max_tokens=2048,
messages=[{
"role": "user",
"content": """以下の要件を満たす Python クラスを実装してください:
1. 非同期 HTTP クライアントのラッパー
2. リトライロジック(指数バックオフ)
3. リクエスト・レスポンスのロギング
4. タイムアウト設定
5. キャッシング機能
"""
}]
)
print(response.content[0].text)理由:
- コード品質が重要
- 複雑な要件理解が必要
- バグの少なさが求められる
コスト削減策: 簡単なコード補完は Flash で対応可能。
2. テキスト要約・翻訳
推奨モデル: Gemini 2.5 Flash → 3 Flash
from anthropic import Anthropic
client = Anthropic()
# テキスト要約は Flash で十分
documents = [
"長いニュース記事...",
"技術ブログ...",
"研究論文のアブストラクト..."
]
for doc in documents:
response = client.messages.create(
model="gemini-2.5-flash",
max_tokens=500,
messages=[{
"role": "user",
"content": f"以下のテキストを3文で要約してください:\n{doc}"
}]
)
print(response.content[0].text)理由:
- タスク複雑度が低い
- Flash で品質を十分確保
- コスト効率が良い
3. リアルタイムチャット・ストリーミング応答
推奨モデル: Gemini 2.5 Flash Lite
from anthropic import Anthropic
client = Anthropic()
def stream_chat(user_message):
"""リアルタイムチャット機能"""
with client.messages.stream(
model="gemini-2.5-flash-lite",
max_tokens=1024,
messages=[{
"role": "user",
"content": user_message
}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
print()
# 使用例
stream_chat("Python の async/await について簡潔に説明してください")理由:
- 低遅延が重要
- Flash Lite が最速
- ユーザーが即座に反応を感じる
4. 複雑な推論・分析・意思決定支援
推奨モデル: Gemini 3 Pro
from anthropic import Anthropic
client = Anthropic()
# 複雑な分析は最新 Pro を使用
response = client.messages.create(
model="gemini-3-pro",
max_tokens=2048,
messages=[{
"role": "user",
"content": """市場データを分析して、以下について詳細に説明してください:
1. 現在のマーケットトレンド
2. 3つの主要なリスク要因
3. 推奨される戦略
4. 実装のロードマップ
"""
}]
)
print(response.content[0].text)理由:
- 最高の推論精度が必要
- 2M トークンのコンテキストで複雑な分析可能
- 戦略的な意思決定に使用
5. マルチモーダル処理(画像・音声・動画)
推奨モデル: Gemini 2.5 Pro / 3 Pro
import base64
from pathlib import Path
# 画像分析の例
def analyze_image(image_path):
"""画像を分析する"""
with open(image_path, "rb") as f:
image_data = base64.standard_b64encode(f.read()).decode("utf-8")
response = client.messages.create(
model="gemini-2.5-pro",
max_tokens=1024,
messages=[{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": image_data
}
},
{
"type": "text",
"text": "この画像に含まれるオブジェクト、テキスト、コンテキストを詳細に説明してください"
}
]
}]
)
return response.content[0].text
# 使用例
analysis = analyze_image("chart.jpg")
print(analysis)理由:
- マルチモーダル処理は計算コスト高
- Pro/高性能モデルが必要
- 画像解析品質が重要
6. 大規模ドキュメント処理(RAG)
推奨モデル: Gemini 3 Pro / 2.5 Pro
from anthropic import Anthropic
client = Anthropic()
def process_large_document(document_path, query):
"""大規模ドキュメントから情報を抽出"""
# ドキュメント読み込み
with open(document_path, "r") as f:
document_content = f.read()
# 2M トークンのコンテキストウィンドウを活用
response = client.messages.create(
model="gemini-3-pro",
max_tokens=1024,
messages=[{
"role": "user",
"content": f"""以下のドキュメントに基づいて質問に答えてください:
<document>
{document_content}
</document>
質問: {query}"""
}]
)
return response.content[0].text
# 使用例
answer = process_large_document("annual_report.txt", "2024年の主要な成長ドライバーは何ですか?")
print(answer)理由:
- 大規模コンテキスト処理に対応
- 複数ドキュメントを同時処理
- コンテキストウィンドウの最大活用
モデル選択の意思決定フロー
入力トークン数は?
├─ < 100K → Flash Lite を検討
├─ 100K-500K → Flash または Pro
└─ > 500K → Pro/Gemini 3 Pro
タスク複雑度は?
├─ 低(要約・翻訳・分類)
│ └─ Flash / Flash Lite
├─ 中(一般的なQA・チャット)
│ └─ Flash / 2.5 Pro
└─ 高(推論・分析・コーディング)
└─ Pro / Gemini 3 Pro
実行速度は重要?
├─ はい → Flash Lite / Flash
└─ いいえ → Pro / 3 Pro
予算は限定的?
├─ はい → Flash Lite / Flash
└─ いいえ → Pro / 3 Pro
ベストプラクティス
1. モデルカスケーディング
def smart_model_selection(task_type, input_tokens):
"""タスク複雑度とトークン数に基づいて最適モデルを選択"""
if input_tokens > 1_500_000:
return "gemini-3-pro" # 最大コンテキスト対応
complexity_to_model = {
"simple_qa": "gemini-2.5-flash-lite",
"chat": "gemini-2.5-flash",
"analysis": "gemini-2.5-pro",
"coding": "gemini-2.5-pro",
"reasoning": "gemini-3-pro"
}
return complexity_to_model.get(task_type, "gemini-2.5-flash")
# 使用例
model = smart_model_selection("coding", 50000)
print(f"選択されたモデル: {model}")2. コスト監視
import json
from datetime import datetime
class APIUsageTracker:
"""API 利用コストを追跡"""
def __init__(self):
self.usage_log = []
self.pricing = {
"gemini-2.5-pro": {"input": 0.30, "output": 1.20},
"gemini-2.5-flash": {"input": 0.10, "output": 0.40},
}
def log_usage(self, model, input_tokens, output_tokens):
"""利用状況をログに記録"""
rates = self.pricing.get(model, {})
cost = (input_tokens / 1_000_000) * rates["input"] + \
(output_tokens / 1_000_000) * rates["output"]
self.usage_log.append({
"timestamp": datetime.now().isoformat(),
"model": model,
"input_tokens": input_tokens,
"output_tokens": output_tokens,
"cost": cost
})
return cost
def get_daily_cost(self):
"""本日のコストを計算"""
today = datetime.now().date()
today_usage = [u for u in self.usage_log
if datetime.fromisoformat(u["timestamp"]).date() == today]
return sum(u["cost"] for u in today_usage)
# 使用例
tracker = APIUsageTracker()
cost = tracker.log_usage("gemini-2.5-flash", 50000, 10000)
print(f"このリクエストのコスト: ${cost:.4f}")
print(f"本日のコスト: ${tracker.get_daily_cost():.2f}")全体を振り返って
| タスク | 推奨モデル | 理由 | |--------|-----------|------| | 簡単なQA・翻訳 | Flash Lite / Flash | 低コスト・高速 | | 通常のチャット | Flash | バランス型 | | コーディング | 2.5 Pro / 3 Pro | 高精度 | | 複雑な推論 | 3 Pro | 最高性能 | | マルチモーダル | 2.5 Pro / 3 Pro | 処理能力 | | 大規模ドキュメント | 3 Pro | コンテキストウィンドウ |
モデル選択は「タスク複雑度」「入力サイズ」「レスポンス速度」「予算」の4軸で判断します。定期的にモデルを見直し、最新の性能改善を活用しましょう。