生成AI入門 2026.04.19
【2026年版】Claude Sonnet 4.5料金完全ガイド|API・Claude Pro・Max使い分けと月額コスト試算
2026年版 Claude APIモデル料金表
| モデル | 入力 $/1M | 出力 $/1M | コンテキスト |
|---|---|---|---|
| claude-haiku-4-5-20251001 | $0.80 | $4.00 | 200K |
| claude-sonnet-4-5 | $3.00 | $15.00 | 200K |
| claude-opus-5 | $15.00 | $75.00 | 200K |
Batches API: 上記の50%オフ / Prompt Caching: キャッシュ読み込み90%オフ
Claude.ai vs API 料金比較
| プラン | 月額 | 向いているケース |
|---|---|---|
| 無料 | $0 | 週数回の軽い使用 |
| Pro | $20 | 毎日30〜100回のチャット利用 |
| Max | $100 | 毎日200回以上、Claude Code長時間利用 |
| API従量課金 | 使用量 | アプリ開発・自動化・月により増減 |
月額コスト試算コード
# sonnet_cost_calculator.py
# 自分の使用パターンで月額を計算する
MODELS = {
"claude-haiku-4-5-20251001": (0.80, 4.00),
"claude-sonnet-4-5": (3.00, 15.00),
"claude-opus-5": (15.00, 75.00),
}
def monthly_cost(model: str, daily_requests: int,
avg_input: int = 1500, avg_output: int = 800,
use_batches: bool = False,
cache_hit_rate: float = 0.0) -> dict:
"""月額コストを試算する(Batches割引・Caching効果を含む)"""
inp, out = MODELS[model]
cached_inp = avg_input * cache_hit_rate * 0.1 # キャッシュ分は90%オフ
uncached_inp = avg_input * (1 - cache_hit_rate)
per_req = ((uncached_inp + cached_inp) * inp + avg_output * out) / 1_000_000
if use_batches:
per_req *= 0.5
monthly = per_req * daily_requests * 30
return {
"model": model,
"monthly_usd": round(monthly, 2),
"vs_pro_plan": "APIが安い" if monthly < 20 else f"Pro検討 (差額${monthly - 20:.0f})"
}
# 使用例: 1日50リクエスト、入力1500・出力800トークン
print("=== 1日50リクエスト試算 ===")
for model in MODELS:
result = monthly_cost(model, 50)
print(f"{model}: ${result['monthly_usd']}/月 - {result['vs_pro_plan']}")
print("\n=== Batches API (50%オフ) ===")
for model in MODELS:
result = monthly_cost(model, 50, use_batches=True)
print(f"{model}: ${result['monthly_usd']}/月")
print("\n=== Prompt Caching (キャッシュ率70%) ===")
for model in MODELS:
result = monthly_cost(model, 50, cache_hit_rate=0.7)
print(f"{model}: ${result['monthly_usd']}/月")
Sonnetでコスト効率を最大化するコード
# efficient_sonnet.py
# Prompt Caching + 適切なmax_tokensでコストを最小化
import anthropic
client = anthropic.Anthropic()
SYSTEM_PROMPT = """あなたはPythonのコーディングアシスタントです。
コードは型安全でテスト可能な設計を優先します。
エラーハンドリングを含めた完全な実装を提供してください。"""
def ask_sonnet_efficient(question: str, long_context: str = None) -> str:
"""Prompt Cachingを活用した効率的なSonnet呼び出し"""
if long_context:
# 長いコンテキスト(コードベース等)はキャッシュ
messages = [{
"role": "user",
"content": [
{
"type": "text",
"text": long_context,
"cache_control": {"type": "ephemeral"}
},
{"type": "text", "text": question}
]
}]
else:
messages = [{"role": "user", "content": question}]
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024, # 必要最小限のmax_tokens
system=SYSTEM_PROMPT,
messages=messages
)
inp = response.usage.input_tokens
out = response.usage.output_tokens
cost = (inp * 3.0 + out * 15.0) / 1_000_000
print(f"[cost] ${cost:.4f} ({inp}in + {out}out tokens)")
return response.content[0].text