Rend Developers

Guides

Prompt caching

When a request starts the same way as one before it, the model reads that shared start from cache. Cached input costs a fraction of normal input: $0.038 instead of $0.528 per million tokens on Rend Swift, and $0.30 instead of $3.00 on Rend Pro.

Caching is automatic. There is nothing to turn on, and it never changes the reply.

How to get the most from it

Because Rend sends your messages exactly as you wrote them, with nothing added in front, the cache sees exactly what you send.

  • Put what stays the same first. System prompt, instructions, tool definitions and long documents go at the start. What changes per request goes at the end.
  • Append, don’t rewrite. In a conversation, add each new turn to the end and leave earlier messages untouched. Turn 10 then reads turns 1 to 9 from cache.
  • Keep the bytes identical. A changed timestamp, a reordered tool list or a different whitespace near the start breaks the match from that point on.
  • Send a prompt_cache_key to group requests that share a prefix, such as one key per conversation or per user. The key is a hint; what decides a cache hit is the matching start of the prompt, so the rules above matter most.
curl https://api.rend.ai/v1/chat/completions \
-H "Authorization: Bearer $REND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "model": "rend-swift",
  "prompt_cache_key": "conversation-8841",
  "messages": [
    {"role": "system", "content": "<your long, unchanging instructions>"},
    {"role": "user", "content": "First question"}
  ]
}'

prompt_cache_key is any string up to 256 characters. Keys are private to your account: every key on the account shares the same cache, and no other account can reach it.

See what was cached

usage.prompt_tokens_details.cached_tokens is how many prompt tokens were read from cache, and usage.cost_details.cached_input is what they cost.

JSON
"usage": {
  "prompt_tokens": 48210,
  "prompt_tokens_details": { "cached_tokens": 47872 },
  "cost_details": { "input": 0.000178, "cached_input": 0.001819, "output": 0.00211, "search": 0 }
}

Good to know

  • A cache does not last forever. A conversation that pauses for a while may pay the normal input price on its next turn, then reads from cache again.
  • Caching is best effort: now and then a request misses and is billed at the normal input price.
  • Compaction keeps the start of your conversation as it was, so a compacted conversation still reads its prefix from cache.