生成AI入門 2026.04.29
【2026年版】Claude Opus 5 vs GPT-5 vs DeepSeek V4 Pro|コード精度・料金・API速度実測比較
2026年の料金比較表
| モデル | 入力 ($/1Mトークン) | 出力 ($/1Mトークン) | コンテキスト |
|---|---|---|---|
| Claude Haiku 4.5 | $0.80 | $4.00 | 200K |
| Claude Sonnet 4.5 | $3.00 | $15.00 | 200K |
| Claude Opus 5 | $15.00 | $75.00 | 200K |
| GPT-4o mini | $0.15 | $0.60 | 128K |
| GPT-5 | ~$10.00 | ~$30.00 | 128K |
| DeepSeek V4 Pro | ~$0.50 | ~$2.00 | 64K |
※ GPT-5・DeepSeek V4 Proの料金は2026年4月時点の推定値。公式サイトで要確認。
Python で3つのAPIを切り替える
# model_switcher.py
# LiteLLMで複数LLMを統一インターフェースで使う
# pip install litellm anthropic openai
import os
import time
from litellm import completion
def call_model(model: str, prompt: str, max_tokens: int = 512) -> dict:
"""モデルを切り替えて同じプロンプトを実行する"""
t = time.time()
response = completion(
model=model,
messages=[{"role": "user", "content": prompt}],
max_tokens=max_tokens,
)
elapsed = time.time() - t
text = response.choices[0].message.content
return {
"model": model,
"text": text,
"elapsed_s": round(elapsed, 2),
"input_tokens": response.usage.prompt_tokens,
"output_tokens": response.usage.completion_tokens,
}
# 対応モデルの設定
MODELS = {
"claude": "anthropic/claude-sonnet-4-5", # AnthropicのAPI
"gpt5": "gpt-5", # OpenAIのAPI
"deepseek": "deepseek/deepseek-chat", # DeepSeekのAPI
}
def benchmark(prompt: str) -> list[dict]:
"""3モデルに同じプロンプトを投げて比較する"""
results = []
for name, model_id in MODELS.items():
result = call_model(model_id, prompt)
result["name"] = name
results.append(result)
print(f"{name}: {result['elapsed_s']}s ({result['output_tokens']} tokens)")
return results
# 使用例
results = benchmark("PythonでシングルトンパターンをThread-Safeに実装して")
for r in results:
print(f"\n=== {r['name']} ({r['model']}) ===")
print(r["text"][:400])
実測データ比較
# hallucination_test.py
# 本番Javaコードでのハルシネーション率測定(簡易版)
import anthropic
import openai
def test_hallucination(prompt: str, correct_api: str) -> dict:
"""
APIが正しく存在するかを確認するテスト。
correct_api: 正しいメソッド名(例: "Thread.currentThread().getStackTrace()")
"""
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=256,
messages=[{"role": "user", "content": prompt}]
)
generated_code = response.content[0].text
# 正しいAPIが使われているか確認
is_correct = correct_api in generated_code
return {
"model": "claude-sonnet-4-5",
"generated": generated_code[:200],
"expected_api": correct_api,
"correct": is_correct,
}
# テストケース例
test = test_hallucination(
prompt="Javaで現在のスタックトレースを取得するコードを書いて",
correct_api="Thread.currentThread().getStackTrace()"
)
print(f"正解: {test['correct']}")
# 10K OSS repoでの実測報告値(引用元論文より):
HALLUCINATION_RATES = {
"gpt-5": 0.07, # 7%(最低)
"claude-sonnet": 0.10, # 10%
"deepseek-v4-pro": 0.15, # 15%(最高)
}
コスト計算:同じタスクで比較
# cost_comparison.py
# 1000リクエスト/日の運用コスト試算
def monthly_cost(
input_tokens_per_req: int,
output_tokens_per_req: int,
requests_per_day: int,
input_price: float,
output_price: float,
) -> float:
"""月額コストを計算(USD)"""
daily_input = input_tokens_per_req * requests_per_day
daily_output = output_tokens_per_req * requests_per_day
daily_cost = (daily_input * input_price + daily_output * output_price) / 1_000_000
return daily_cost * 30
# 典型的なコード生成リクエスト(入力2000・出力800トークン)
SCENARIO = {"input_tokens_per_req": 2000, "output_tokens_per_req": 800, "requests_per_day": 1000}
models = {
"Claude Haiku 4.5": (0.80, 4.00),
"Claude Sonnet 4.5": (3.00, 15.00),
"DeepSeek V4 Pro": (0.50, 2.00),
"GPT-5 (推定)": (10.00, 30.00),
}
print("月額コスト比較(1000リクエスト/日)")
for model, (inp, out) in models.items():
cost = monthly_cost(**SCENARIO, input_price=inp, output_price=out)
print(f" {model}: ${cost:.0f}/月")
# 出力例:
# Claude Haiku 4.5: $144/月
# Claude Sonnet 4.5: $540/月
# DeepSeek V4 Pro: $90/月
# GPT-5 (推定): $1,800/月
用途別の選び方
| 用途 | 推奨モデル | 理由 |
|---|---|---|
| コスト重視の大量処理 | DeepSeek V4 Pro / Claude Haiku | 最安値 |
| コード生成品質重視 | GPT-5 / Claude Sonnet 4.5 | ハルシネーション率低い |
| 長文ドキュメント処理 | Claude Opus 5 | 200Kトークン + 長文精度 |
| ファインチューニング | DeepSeek V4 Pro | 速度・コスト優位 |
| 日本語コンテンツ | Claude Sonnet 4.5 / GPT-5 | 日本語品質高い |
あわせて読みたい
- 【2026年版】Claude Opus・Sonnet・Haiku 違いと選び方
- Claude vs ChatGPT【2026年版】料金・性能・用途別比較
- OpusがSonnetを指揮する2モデル協調パターン|コスト削減実装