🎁 新規 無料登録、10回の呼び出しを進呈。最大 $1、カード不要。

Prompt Caching(プロンプトキャッシュ)

Prompt caching は繰り返されるプレフィックスを通常の入力料金より大幅に安く課金します。ゲートウェイの背後にある各プロバイダーでやり方が少しずつ異なり(プレフィックスの明示が必要なもの、自動でキャッシュするもの)、割引はプロバイダー料率のまま転送されます。

有効化の 2 つの方式

Explicit providers cache only the prefix you mark. On this gateway cache_control is forwarded on the Anthropic-compatible path; other providers expose their explicit caching through their own APIs rather than through this endpoint. Automatic providers cache any prefix past a minimum length with no code change. Which applies depends on the model you call.

プレフィックスを明示する

安定した部分を先頭に置き、その最後のブロックに印を付けます。印より前のすべてがキャッシュ対象のプレフィックスになるため、呼び出し間でその部分はバイト単位で同一である必要があります:

curl https://synthorai.io/v1/chat/completions \
  -H "Authorization: Bearer $SYNTHORAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "messages": [
      {"role": "system", "content": [
        {"type": "text", "text": "<your long, stable system prompt>",
         "cache_control": {"type": "ephemeral"}}
      ]},
      {"role": "user", "content": "The part that changes every call."}
    ]
  }'

プロバイダー別の挙動

各プロバイダーの最小プレフィックス、キャッシュ保持時間、書き込み追加料金:

プロバイダー 有効化の方式 Min prefix (provider default) 保持時間 書き込みコスト
Alibaba 明示型 + 自動 explicit: 5m, reset on hit
Anthropic 明示型(プレフィックスに印) 1,024 5m default, 1h option 1.25x (5m) / 2x (1h)
ByteDance 明示型 + 自動 1,024
DeepSeek 自動
Google 明示型 + 自動 1,024
MiniMax 自動 512
Moonshot 自動
OpenAI 自動 1,024 5–10m, up to 1h
Z.ai 自動

Transcribed from each provider's own documentation; a provider whose semantics we have not verified against its docs is left out rather than guessed at. The minimum shown is the provider's default — individual models set their own, some higher and some lower (several Claude models require 4,096 tokens, one needs only 512). The model's own page carries the figure that applies to it. Where the mode says explicit, marking a prefix with cache_control works on the Anthropic-compatible path; other providers expose explicit caching through their own APIs instead.

請求への現れ方

Cached reads bill at a separate, lower input rate — visible per request in usage, and per model on its price page. Where a provider charges to write the cache, the first call costs more than plain input, so caching pays off from the second identical prefix onward. Models with no separate write rate simply bill the write at normal input price.

よくある間違い

  • 可変部分を先頭に置く。キャッシュはプレフィックス一致です。プロンプト冒頭のタイムスタンプやユーザー ID は、それ以降すべてを無効化します。
  • Prefixes under the minimum. Below the threshold nothing is cached and nothing is reported — it looks like caching silently failed. Check the model page rather than this table: several models require a higher minimum than their provider's default.
  • 保持時間より長い呼び出し間隔。TTL を超えるアイドルがあると、次の呼び出しで書き込みコストを再び支払います。

リクエストボディの完全なリファレンス: Chat Completions