🎁 신규 무료 가입, 10회 호출 제공. 최대 $1, 카드 불필요.

Prompt Caching(프롬프트 캐싱)

Prompt caching은 반복되는 프리픽스를 일반 입력 요금보다 훨씬 싸게 과금합니다. 게이트웨이 뒤의 각 공급사마다 방식이 조금씩 달라(프리픽스 표시가 필요한 곳, 자동으로 캐싱하는 곳) 할인은 공급사 요율 그대로 전달됩니다.

활성화하는 두 가지 방식

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