---
title: "How Long Does DeepSeek Cache Prompts, and How Do You Pay Less?"
url: "https://goremy.ai/blog/articles/deepseek-prompt-caching-how-long-and-cost"
author: Luis Chavez-Mattos
editor: Luis Chavez-Mattos
editor_title: Director, Product
published: "2026-10-22T23:00:08.022Z"
updated: "2026-10-22T23:00:09.647Z"
topic: AI Pricing & Usage Limits
description: "DeepSeek keeps its KV cache on disk for 3 days (agents) or 7 days (chat), and 96% of input tokens hit cache. Learn to keep prefixes stable and cut API cost."
---

# How Long Does DeepSeek Cache Prompts, and How Do You Pay Less?

> DeepSeek keeps its KV cache on disk for 3 days (agents) or 7 days (chat), and 96% of input tokens hit cache. Learn to keep prefixes stable and cut API cost.

Edited by Luis Chavez-Mattos, Director, Product · Published 2026-10-22

## How long does DeepSeek cache prompts?

According to DeepSeek's inference write-up, it keeps the KV cache (the model's saved memory of a prompt it has already read) on disk for days, not minutes. Agent traffic is retained for 3 days and chat traffic for 7 days. Many providers keep a prompt cache live for only about 5 minutes. To get the cached-input discount, keep the start of every request identical to the previous one.

## TL;DR

- DeepSeek stores its **KV cache on disk for 3 days for agent traffic and 7 days for chat**, far longer than the roughly 5 minutes typical elsewhere.
- DeepSeek says **96% of all input tokens are cache hits**, so the model reads only about 4 of every 100 input tokens from scratch.
- Cached input costs less because **the model skips the expensive prefill work** for text it has already processed.
- For agents that resend long context every turn, **a stable prompt prefix is the cheapest optimization** available.
- The cache system itself is **not part of the open-source release**. You get a description of it, not the code.
- Cache hits depend on matching the earlier prompt from the start, so **anything that changes early in the prompt invalidates what follows**.

## What is the KV cache and why does it matter for cost?

When a model receives a prompt, it first runs a phase called prefill. It reads the whole prompt in one large parallel pass and builds a working memory of it. That memory is the KV cache. Prefill is a mountain of math done at once.

The second phase, decode, writes the reply one token at a time. Each token waits on the one before it.

If you send a follow-up message in a conversation, everything before it has already been read once. Recomputing it wastes GPU time. If the server still holds the saved memory, it can load that and run prefill only on the new part. That saved work is why the API charges less for cached input.

## Why does DeepSeek keep the cache for days?

DeepSeek stores the cache on a dedicated data cluster with about 100 petabytes of SSD. Disk is far cheaper per byte than GPU memory, so keeping entries for days is affordable. A longer lifetime means more requests land on a prefix that is still stored.

The payoff, per DeepSeek, is that 96% of input tokens are cache hits. That is the figure behind the pricing gap. The company is also serving a very large volume (it cites 155 trillion tokens a day on a single cluster running this stack), and skipping repeated reading is a big part of making that workable.

| Traffic type | Reported cache retention |
|---|---|
| Agent | 3 days |
| Chat | 7 days |
| Typical provider (per the source) | About 5 minutes |

## How do you structure requests to get the cached-input discount?

The principle is simple. A cache hit needs the beginning of your new prompt to match something already processed. So put stable content first and changing content last.

A practical layout for an agent loop:

1. System prompt and instructions, unchanged between turns.
2. Tool definitions, in a fixed order.
3. Long reference material or code context, added once and not rewritten.
4. Conversation history, appended turn by turn without editing earlier turns.
5. The newest user message or tool result, at the very end.

Only step 5 and any new appended history need fresh prefill. Everything before it can be served from cache.

## What breaks a cache hit?

Prefix matching is unforgiving. Small edits near the top invalidate everything after them. Common culprits, based on how prefix caching works in general:

- Putting a timestamp, request ID, or session token in the system prompt.
- Reordering tool definitions or regenerating them in a different order.
- Rewriting or summarizing earlier turns in place instead of appending.
- Inserting new context at the top rather than the bottom.
- Switching system prompt wording between calls "just a bit."

The source also notes that DeepSeek adds a reasoning effort line to the system prompt by default. If you change that setting between calls, expect it to alter the prompt text near the front. Keep it consistent within a session.

## Why do agent loops benefit the most?

An agent resends its entire context on every step. A coding agent might carry a system prompt, tool schemas, a large chunk of a code base, and a growing log of actions. Each step adds a little and repeats a lot. Without caching, you pay full input price for the repeated part on every turn.

With a stable prefix, the repeated portion is mostly cache hits. The new tokens are a small slice. DeepSeek's own advice, as relayed in the source, is that keeping the prefix stable is the cheapest optimization for agent builders.

## Does caching change the answers you get?

Caching itself should not. The prefill output is the same memory the model would have built anyway. A separate issue is worth knowing about, though. On a busy server, a prompt at temperature zero can return slightly different output depending on what else shares its batch. GPUs may add numbers in a different order depending on batch size, and tiny rounding differences can flip which token wins.

DeepSeek's engine has a batch-invariant mode that forces the same math regardless of batch contents. It is off by default because it is slower. The source's author reproduced the same kind of drift on a laptop with a small open model. If you need reproducible results for evals or agent debugging, that mode is the relevant setting, though it applies to the open-source engine rather than the hosted API as far as the sources show.

## Can you run this caching system yourself?

Not fully. DeepSeek open-sourced its inference engine, but the open version only does offline inference, with no API server. The KV cache storage system and the load balancers are tied to DeepSeek's internal infrastructure, so they are described but not released. The kernels also target Nvidia's data center Blackwell chips such as the B200, and the source's author found they would not build on other Blackwell hardware like a DGX box.

If you self-host a DeepSeek model, the source notes it already runs on regular engines like vLLM. The lesson that carries over is the habit of stable prefixes, which helps with any prefix-caching setup.

## Is it worth restructuring prompts for caching?

If you send the same long context repeatedly, yes. The change costs almost nothing: reorder content, stop injecting volatile values at the top, and append instead of rewriting. For one-off prompts with little shared text, there is little to gain. Check your provider's usage data for cache-hit counts to confirm the change worked.

## Frequently Asked Questions

### How long does DeepSeek keep a cached prompt?
DeepSeek says it holds the KV cache on disk for 3 days for agent traffic and 7 days for chat. That is much longer than the roughly 5 minutes common at other providers. Retention is a policy detail from DeepSeek's write-up, so check current API docs for guarantees.

### What share of DeepSeek input tokens are cache hits?
DeepSeek reports that 96% of all input tokens are cache hits. In practice the model reads only about 4 of every 100 input tokens for real. That is the basis for the lower price on cached input.

### What is the easiest way to get more cache hits?
Keep the start of your prompt identical across calls. Put system instructions, tool definitions, and reference material first, and append new messages at the end. Avoid timestamps or random IDs near the top.

### Does the cached-input discount apply to chat and agents equally?
The source describes both traffic types as using the cache, with different retention windows. It does not give exact per-token prices, so consult DeepSeek's pricing page for current cached and uncached rates.
