Skip to content
NewTry RouterPlus with free creditsTry playground →

Prompt caching on open-model APIs

Reuse the same prompt start and supporting providers bill it at a lower cached rate.

GLM 5.3 FlashMorph, default route
  • Input$0.18
  • 80% cached$0.0648
  • Cached$0.036

USD per 1M input tokens

What prompt caching is

Prompt caching lets a provider reuse the work it already did on the start of a prompt. When a request opens with the same tokens as a recent one, that part is read from cache and billed at the cached input price.

Prices from the RouterPlus catalog, December 5, 2026. Docs checked December 3, 2026.

  • 174of 182 provider listings on RouterPlus model pages show a cached input price
  • 39open-weight models have at least one provider with a cached price
  • 18%median cached price as a share of the same listing's input price

When caching pays

  • Long shared prefixes

    A system prompt, tool definitions or examples that open every request. The longer the fixed start, the more of each call bills at the cached rate.

  • Agents

    Your app sends the full conversation on every turn. Keep earlier messages unchanged and only append, so each turn opens with the start of the last one.

  • RAG on the same documents

    Many questions against one contract, codebase or manual. Keep those documents in the stable part, and put content retrieved for each turn after it.

It pays little on short prompts, on prompts that change near the start, and on traffic too sparse to keep a cache warm. Providers cache a prompt start once it passes a minimum length, and caches expire.

Cached vs uncached prices

The 10 open-weight models with the most providers listing a cached price, at each model's default route: the provider where routing starts.

ModelDefault routeInputCached inputCached vs inputInput at 80% cachedProviders with a cached price
GLM 5.3 Flashz-ai/glm-5.3-flashMorph$0.18$0.03620%$0.064818 of 18
GLM 5.3z-ai/glm-5.3Morph$1.68$0.3118%$0.58417 of 17
DeepSeek V4.1 Flash 1017deepseek/deepseek-v4.1-flash-1017Nebius$0.30$0.0062%$0.064814 of 14
Qwen3.8 27Bqwen/qwen3.8-27bNebius$0.45$0.1022%$0.1712 of 12
DeepSeek V4 Flash 0731deepseek/deepseek-v4-flash-0731DeepInfra$0.06$0.01525%$0.0249 of 9
DeepSeek V4.1 Flashdeepseek/deepseek-v4.1-flashMorph$0.12$0.0087%$0.03049 of 9
GLM 5.2z-ai/glm-5.2Morph$1.40$0.2619%$0.4889 of 9
Kimi K3moonshotai/kimi-k3Morph$2.50$0.2912%$0.7329 of 9
Kimi K3.1 Promoonshotai/kimi-k3.1-proMorph$2.50$0.2912%$0.7327 of 7
DeepSeek V4 Pro 0813deepseek/deepseek-v4-pro-0813DeepInfra$1.30$0.108%$0.346 of 6

USD per 1M input tokens, as of December 5, 2026. Input at 80% cached = 20% of tokens at the input price plus 80% at the cached price, before any cache write. Providers set their own rates; each model page lists every provider.

How routing affects hits

A provider keeps a prompt's cache on one machine. The cache saves money when the next request reaches the same provider with the same prompt start. A turn sent somewhere new starts cold.

Input tokens per turn of one agent sessionExample

  • Turn 1Provider ACold start
  • Turn 2Provider ACache hit
  • Turn 3Provider ACache hit
  • Turn 4Provider BMoved, cold
  • Turn 5Provider BCache hit
Read from cacheBilled at full input price

What RouterPlus does

  • Same route first

    Routing is deterministic. For the same model, key and provider object, every request tries the same route first, with or without a session ID.

  • Session IDs passed through

    Send one session ID per conversation. RouterPlus gives it to each provider in that provider's own field, so the provider can send the conversation back to the machine holding its cache.

  • A short wait before moving

    When the capacity pool for your first route is full, a follow-up turn waits up to 5 seconds for that route instead of moving to a cold cache.

What each route receives

RouteSession field sent
OpenAI (house or BYOK), Azureprompt_cache_key: yours, else the session ID
Morphx-session-id header: the session ID, else your prompt_cache_key
Anthropic, BedrockNothing: the cache matches the prompt prefix
DeepInfraNothing: the cache matches the prefix without a key

A turn moves to the next provider of the same model when the first route fails before it sends output, its capacity pool stays full, or the provider's 429 pause is still running. After two failures in a row, later turns skip that route for 30 seconds. A turn that moves can miss the cache one time.

Send a session ID

Send one ID per conversation as session_id in the body or the x-session-id header. A valid ID is 1 to 256 printable ASCII characters; an invalid one is ignored with no error.

Python, openai package
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.routerplus.com/v1",
    api_key=os.environ["ROUTERPLUS_API_KEY"],
)

SYSTEM = open("system_prompt.md").read()  # long and fixed: the cached start

reply = client.chat.completions.create(
    model="z-ai/glm-5.3-flash",
    messages=[
        {"role": "system", "content": SYSTEM},
        {"role": "user", "content": "Summarize ticket 4812."},
    ],
    extra_body={"session_id": "ticket-4812"},  # one ID per conversation
)

print(reply.usage.prompt_tokens_details.cached_tokens)  # tokens read from cache
print(reply.usage.cost)  # USD for this request
curl
curl https://api.routerplus.com/v1/chat/completions \
  -H "Authorization: Bearer $ROUTERPLUS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-session-id: ticket-4812" \
  -d '{
    "model": "z-ai/glm-5.3-flash",
    "messages": [
      { "role": "system", "content": "<long fixed system prompt>" },
      { "role": "user", "content": "Summarize ticket 4812." }
    ]
  }'

Field names and order from the RouterPlus docs.

Keep the prompt start fixed

Keep the start byte-identical
The same system prompt, the same tool definitions in the same order, and earlier messages unchanged. Add new content at the end.
Put changing content last
The time, IDs and documents retrieved for this turn go after the stable part.
Hold the model and provider object
Keep both the same for every turn of a session, so every turn tries the same route first.
Clear the minimum length
A provider caches a prompt start once it passes a minimum length. A short system prompt shows no cache reads.

Measure your hit rate

Divide cache reads by prompt tokens on each response. usage.cost is the full charge for the request, including any failed attempts on other providers.

MeasuresUsage field
Cache readsOpenAI-compatibleusage.prompt_tokens_details.cached_tokens
Cache writesOpenAI-compatibleusage.prompt_tokens_details.cache_write_tokens
Cache readsAnthropic-compatibleusage.cache_read_input_tokens
Cache writesAnthropic-compatibleusage.cache_creation_input_tokens

Questions teams ask

What is prompt caching?

Prompt caching lets a provider reuse the work it already did on the start of a prompt. When a request begins with the same tokens as a recent one, the provider reads that part from its cache and bills it at the cached input price instead of the full input price.

How much cheaper are cached tokens?

Across RouterPlus model pages, 174 of 182 provider listings show a cached input price, at a median of 18% of that listing's input price (catalog as of December 5, 2026). Output tokens are not cached. Each model page lists every provider's input, cached and output price.

Do I need to change my code?

Often not. Turns of a session already try the same route first, and some providers cache long prompt starts on their own. To help providers that place conversations by key, send one session_id per conversation in the request body or the x-session-id header. Keep the prompt start identical and add new content at the end.

Which provider does each turn go to?

Routing is deterministic: for the same model, key and provider object, every request tries the same route first. A turn moves when that route fails before output, its capacity pool stays full, or the provider has paused it after a 429. It moves to another provider of the same model, and a moved turn can miss the cache one time.

What does session_id do?

RouterPlus passes it to each provider in that provider's own field: prompt_cache_key on OpenAI and Azure routes and the x-session-id header on Morph. Anthropic, Bedrock and DeepInfra get nothing because their caches match the prompt prefix. A valid value is 1 to 256 printable ASCII characters; an invalid one is ignored.

Do cache writes cost extra?

On some routes. With automatic caching on Claude, served by Anthropic's own API (the marketplace's anthropic route or your own Anthropic connection, not Bedrock), the first turn pays a cache write at 1.25 times the input price and later reads cost a tenth of input or less, per the RouterPlus docs. Routes that bill a write report it as cache_write_tokens or cache_creation_input_tokens in usage.

Why do I see no cached tokens?

The prompt may be below the provider's minimum cacheable length, something near the start changes between requests, the model or provider object changed, the cache expired, or the turn moved to another provider. Check usage.prompt_tokens_details.cached_tokens on each response.

Sources and docs

Docs checked December 3, 2026. Prices refresh from the catalog within about five minutes.

Cache your prompts on one key

Sign up, create a key and call catalog models by ID. Need reserved capacity? Tell us the workload.