Bridge by Wekoya / Docs / Chat

Prompt caching

Updated

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.

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

Get the most from it

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 stores it once for as long as you choose, on Gemini models.