---
title: "Prompt Caching API: Reuse Prefixes Across Models | Straitly Docs"
description: "Send Anthropic cache_control breakpoints or automatic OpenAI caching through Straitly. Cut repeat input costs and verify cache-read tokens in Activity."
url: https://straitly.ai/docs/caching
updated: 2026-11-28
publisher: Straitly (https://straitly.ai)
---

Docs

API guides

# Prompt caching

Copy docs

**On this page**

Prompt caching reuses a matching prompt prefix across requests so repeat system instructions, tool schemas and reference docs are billed at reduced cache-read rates instead of fresh input. Put static context first, append changing user turns last, and verify cache hits in Activity.

### Organize your prompt

Stable prefix

**Reuse** Keep shared instructions, tool definitions, and reference material at the beginning in a consistent order.

Changing suffix

**Append** Put the current question and changing context after the reusable prefix.

Measure

**Cache reads** Inspect reported usage and Activity. A successful response does not necessarily mean there was a cache hit.

Changing models, routes, or prompt prefixes can affect reuse. Do not assume cache state is shared across every provider or that a short test prompt meets the cache threshold.

### Anthropic cache breakpoint

For a model supporting Anthropic prompt caching, a cache\_control marker identifies the end of a reusable content block. This Messages API example is a request-shape example; replace the short reference text with your actual reusable material. It does not guarantee a cache hit.

Python

Copy Copied Failed

import os
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.straitly.ai",
    api_key=os.environ["STRAITLY_API_KEY"],
)

response = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=256,
    system=[{
        "type": "text",
        "text": "Answer using this reference: <your reusable reference>",
        "cache_control": {"type": "ephemeral"},
    }],
    messages=[{"role": "user", "content": "Summarize the reference."}],
)
print(response.usage)
for block in response.content:
    if block.type == "text":
        print(block.text)

Use the provider's current documentation for minimum token thresholds, breakpoint limits, and supported TTLs. OpenAI-format requests do not use this exact Anthropic content-block contract.

### Read cache usage

The first eligible request may write cache entries; a later matching request may read them. Cache reads and cache writes are different billing buckets.

Inspect cache-read, cache-write, and fresh-input tokens in Activity. When using the Anthropic SDK, inspect the usage fields returned by your selected model; do not infer hits from latency alone.

[Request activity](https://straitly.ai/app/activity) [Token rates](https://straitly.ai/docs/models#token-rates) [Claude API pricing and cache rates](https://straitly.ai/claude-api-pricing)

### Cache costs and misses

- Cache writes can cost more than fresh input, while cache reads can cost less. Check all token rates, not only input and output.
- 5-minute and 1-hour cache writes can have different prices. Use the applicable rate when estimating a workload.
- On a miss, check model support, prompt size, expiry, and exact prefix changes. Caching is not a general persistence guarantee.
- Do not use caching as a data-retention promise. Ask support about the handling requirements of sensitive workloads.

### Why did my cache miss?

A cache hit needs the same model, a long enough prompt, and a prefix that matches the earlier request byte for byte while the cache entry is still alive. If cache\_read\_input\_tokens stays at 0 while cache\_creation\_input\_tokens keeps growing, one of these is usually the cause:

Python

Copy Copied Failed

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.straitly.ai/v1",
    api_key=os.environ["STRAITLY_API_KEY"],
)

response = client.chat.completions.create(
    model="claude-sonnet-5-5",
    prompt_cache_key="conversation-123",
    messages=[
        {"role": "system", "content": "<your long, unchanging instructions>"},
        {"role": "user", "content": "The changing question goes last."},
    ],
)
print(response.usage)

- Something early in the prompt changes on every call: a timestamp, a request id, a random order of tools, or a user name in the system prompt. Move anything that changes after the reusable part.
- The prompt is shorter than the model's minimum cacheable length. Short test prompts often never cache. Check the provider's threshold for that model.
- The cache entry expired. A 5-minute write is gone if the next matching call comes later than that. Use a 1-hour write for slower traffic, which is priced differently.
- You switched models. Each model keeps its own cache, so a fallback to a second model starts cold.
- On OpenAI-format requests, send the same prompt\_cache\_key on every turn of one conversation. It helps related requests reach a warm cache. Your own value is passed through as you send it.
- The request moved to another source for the same model after an error. Caches are not shared between sources, so the next call may write the cache again.

Read cache\_read\_input\_tokens and cache\_creation\_input\_tokens in usage, or the cache buckets in Activity, to confirm a hit. Faster replies alone do not prove one.

[Prompt caching savings by provider](https://straitly.ai/prompt-caching-savings) [Models & pricing](https://straitly.ai/docs/models) [Structured outputs](https://straitly.ai/docs/structured-outputs) [Production checklist](https://straitly.ai/docs/production) [Contact support](https://straitly.ai/docs/support)

### Common questions

**How does prompt caching work on Straitly?**

Prompt caching reuses a matching prompt prefix across requests to cut repeat input token cost. Put static system instructions, tool schemas and reference documents at the start of the prompt and append changing user turns at the end.

**How do I enable prompt caching for Claude vs OpenAI models?**

On Anthropic Messages requests, add cache\_control: { type: "ephemeral" } to the end of the reusable content block. OpenAI and other providers use their own automatic or model-specific caching rules, and Straitly passes those cache parameters through unchanged.

**How do I verify a prompt cache hit and its cost?**

Inspect the returned usage fields or open Activity in the console to see fresh input, cache-read, 5-minute cache-write and 1-hour cache-write token buckets separately. Do not infer cache hits from latency alone.

[Streaming](https://straitly.ai/docs/streaming) [Tool calling](https://straitly.ai/docs/tool-calling)

---
Markdown version of https://straitly.ai/docs/caching.
