# Prompt caching

URL: https://bridge.wekoya.tech/docs/prompt-caching
Updated: 2026-11-08

> When your requests start the same way (the same instructions, tools or document), that start is kept warm and read again at the cached rate, often a tenth…

When your requests start the same way (the same instructions, tools or document), that start is kept warm and read again at the cached rate, often a tenth of the input price. It is on for every request; there is nothing to switch on. It is the same caching Wekoya Code uses.

- First request Reads everything, and keeps the start warm.
- Next request, same start The start is read from the cache, at the cheaper rate.
- Only what's new The latest message is the only part read at the full price.

#### Get the most from it

- Put what stays the same first (instructions, tools, documents) and what changes last.
- Name the conversation, so its requests land on the same warm cache: OpenAI's `prompt_cache_key`, or `session_id`, or the `X-Session-Id` header. Use one value per conversation, not per user.
- On Claude models Bridge places the cache points for you and keeps them for up to an hour. You don't need `cache_control`; it is ignored.
- Works on Claude, Gemini, GPT and DeepSeek models. A start shorter than about 1,024 tokens is not cached.

```
import os
from openai import OpenAI

client = OpenAI(base_url="https://wekoya-api.wekoya.tech/v1", api_key=os.environ["WEKOYA_API_KEY"])

reply = client.chat.completions.create(
    model="claude-sonnet-5-5",
    messages=[
        {"role": "system", "content": LONG_INSTRUCTIONS},  # the same every time: first
        *conversation,                                     # what changes: last
    ],
    prompt_cache_key=conversation_id,  # one value per conversation
)

print(reply.usage.prompt_tokens_details.cached_tokens)  # input tokens read from the cache
```

```
curl https://wekoya-api.wekoya.tech/v1/chat/completions \
  -H "Authorization: Bearer $WEKOYA_API_KEY" -H "Content-Type: application/json" \
  -H "X-Session-Id: conversation-42" \
  -d '{"model": "gemini-3.8-flash", "messages": [{"role": "system", "content": "…"}, {"role": "user", "content": "…"}]}'
```

#### See what it saved
`usage.prompt_tokens_details.cached_tokens` is how many input tokens were read from the cache, and `cache_write_tokens` how many were written. Each model's cached price is `cost_per_million.cache_read` in `GET /v1/models`.
Asking many questions about one long document? A [context cache](https://bridge.wekoya.tech/docs/caches) stores it once for as long as you choose, on Gemini models.
