Prompt caching

Repeated prompt prefixes are cached automatically

No request parameter turns it on. Tokens served from cache are billed at the cached-input rate, 5 to 50 times lower than the input rate depending on the model. The script sends one long system prompt twice and prints how many prompt tokens each response took from cache.

Two calls · curl and jq
BASE_URL=https://direct.api.mnma.ai/v1
P=$(python3 -c \
  "print('Fixed text. ' * 4000)")

for q in "Reply OK." "Reply YES."; do
jq -n --arg p "$P" --arg q "$q" '{
  model: "deepseek-v4.1-flash",
  max_tokens: 64,
  messages: [
    {role: "system", content: $p},
    {role: "user", content: $q}]}' |
curl -s $BASE_URL/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d @- |
jq -c '.usage | {prompt_tokens, cached:
  .prompt_tokens_details.cached_tokens}'
done

# A 14,044-token prompt:
{"prompt_tokens":14044,"cached":0}
{"prompt_tokens":14044,"cached":13952}

The check

The second call reported 13,952 of 14,044 prompt tokens as cached

deepseek-v4.1-flash, with no cache parameter in the request.

ModelTestRepeat calls that hitCached tokens on a hit
deepseek-v4.1-flashSame 14,000-token system prompt; the user message differs by one digit2 of 213,952 of 14,044
glm-5.3-flashSame 14,000-token system prompt; the user message differs by one digit2 of 213,824 of 14,465

On glm-5.3-flash the repeat call came back in 1.5 s instead of 3.5 s. Your hit rate, by model and key, is under “Cache hit rate” on the console dashboard.

Cached-input rates

The cached-input rate is 5 to 50 times lower than the input rate

Published prices in USD per 1 million tokens. Output is billed at the output rate whether or not the prompt hit the cache.

ModelInput / 1MCached input / 1MInput ÷ cached
deepseek-v4.1-flash$0.30$0.00650
glm-5.3$1.40$0.265.4
glm-5.3-flash$0.15$0.035
kimi-k3.1-pro$1.715$0.1988.7
qwen3.8-2.4t$2.00$0.258

A bill

The hit rate decides how much of the prefix is billed at the cached rate

So the formula takes the hit rate h as an input. Each response's usage has your own P, U and O: cached_tokens, the rest of prompt_tokens, and completion_tokens.

Cost per call, USD
cost per call = (
    h × P × c
  + (1 − h) × P × i
  + U × i
  + O × o ) / 1,000,000

P  prompt prefix repeated every call
U  new prompt tokens per call
O  output tokens, reasoning included
h  cache hit rate, from 0 to 1
i  input price per 1M tokens
c  cached-input price per 1M tokens
o  output price per 1M tokens
deepseek-v4.1-flash, h = 0.8
( 0.8 × 14,000 × 0.006
+ 0.2 × 14,000 × 0.30
+ 1,000 × 0.30
+ 500 × 1.20 ) / 1,000,000
= (67.2 + 840 + 300 + 600) / 1,000,000
= $0.0018072 per call
× 100,000 calls = $180.72
Prefix P
14,000 tokens
New input U
1,000 tokens
Output O
500 tokens
Calls
100,000
100,000 callsdeepseek-v4.1-flashglm-5.3glm-5.3-flashkimi-k3.1-proqwen3.8-2.4t
0% hit rate$510.00$2,320.00$250.00$3,064.15$3,300.00
50% hit rate$304.20$1,522.00$166.00$2,002.25$2,075.00
80% hit rate$180.72$1,043.20$115.60$1,365.11$1,340.00
100% hit rate$98.40$724.00$82.00$940.35$850.00

Every figure is computed from the published rates.

Cache-friendly prompts

Put what repeats at the start of the prompt and what changes at the end

The cache reuses the identical beginning of a prompt, so one changed token early on makes everything after it new input.

Start of the prompt

The system prompt, tool definitions, reference documents and the earlier turns of the conversation, in the same order on every call.

End of the prompt

Timestamps, request IDs, user names and the new question.