DeepSeek V4: Pricing, Context, and Migration
I keep a cost spreadsheet for every AI pipeline I run. It started as a curiosity. It became a reflex after the first time a side project’s…
DeepSeek V4: Pricing, Context, and Migration

I keep a cost spreadsheet for every AI pipeline I run. It started as a curiosity. It became a reflex after the first time a side project’s API bill hit $400 in a single week.
DeepSeek V4 landed last week and I ran the numbers immediately. V4-Flash: $0.28 per million output tokens. V4-Pro: $3.48. GPT-5.5 is $30. That is a 107x gap at the Flash tier. Not a rounding error. Not a “under specific conditions” asterisk. A straight comparison on output tokens.
Two things stopped me from dismissing this as another “cheap but limited” model. First, the context window. 97% recall at 1M tokens, flat. I will come back to what that number actually means. Second, the migration path: one URL change, one model string. Everything else stays the same.
What 107x Actually Buys You
The headline pricing gap is real, but it does not tell the full story by itself.
For a daily agentic workload that pushes 1 million output tokens, V4-Flash saves $29.72 per day compared to GPT-5.5. That is $891 per month, for a single pipeline. Most people running agentic loops are not at 1M daily output tokens yet. But agentic systems push output on every iteration. Tool result parsing, planning steps, structured extraction, next-action selection. It adds up faster than it seems.
V4-Pro at $3.48 per million is the more interesting comparison for quality work. Claude Opus 4 is $25. That is a 7,2x difference, which is significant when you are routing complex reasoning tasks.
The decision tree once you have access to V4: Flash is the default for any task that does not require sustained multi-step reasoning. Classification, summarization, extraction, tool-result parsing, anything with predictable structure. V4-Pro for planning agents, hard code generation, architecture decisions, anything where you need the full reasoning budget. The 12x price gap between Flash and Pro means you can retry Flash several times before Pro becomes the cheaper option per correct output.
The Context Window That Actually Works
Most long-context claims are marketing. Models report a context length, but retrieval quality degrades sharply past 128K or 256K tokens. You hit the window limit and the model just misses things that are buried deep in the document.
DeepSeek V4 runs an architecture called Engram. The design focuses on keeping positional signal accurate across the full window. The test for this is straightforward: hide a specific fact somewhere in a document and ask the model to find it. Run it at 128K, 256K, 512K, and 1M token depths. V4 scores 97% recall at every depth. Flat. No degradation.
That changes what you can do with long-context workloads. On buildthisnow.com, I build agents that process entire codebases at once. On alumco.io, there are pipelines that pull long manufacturing spec documents. The usual approach involves chunking and retrieval: split the document, embed the chunks, query the index. That works, but it introduces retrieval errors and adds latency. If the model can actually hold 1M tokens in context with reliable recall, you can skip the retrieval layer entirely for a large class of tasks.
V4’s cache pricing makes this even more practical. Load a 500-page document once. The first call pays full input rate. Every follow-up query that references the same document pays cache rates, approximately 95% off the base input price. Twelve queries against the same document at full price becomes one call at full price and eleven calls at 5% of base.
How Caching Changes the Math
Cache hits are where the real cost savings live, and most benchmarks do not include them.
System prompts get cached after the first call. Any token that appears identically at the start of the context on a subsequent call is a cache hit. For an agent with a 10,000-token system prompt running 100 iterations, only the first call pays full price for those system prompt tokens. The other 99 calls pay about $0.004 per million tokens on the cached portion, versus $0.07 for uncached input.
The pattern that compounds fastest: agent loops with static working context. If your agent reads a set of rules, a schema, or reference documentation on every iteration, put that content at the start of the context and keep it there. After the first call, it is effectively free.
One caveat: cache hits require the cached tokens to appear in a consistent order at the start of the context. Dynamic content, like conversation history or tool results, goes at the end. Mixing static and dynamic content mid-context breaks the cache hit. The ordering discipline is worth enforcing in your integration layer.
Why MoE Pricing Makes Sense
Before the migration section, it is worth understanding why V4 can price this low without being a worse model.
Both V4 variants use Mixture-of-Experts (MoE) architecture. Traditional dense models activate all parameters on every forward pass. MoE models route each token through a small subset of specialized experts. V4-Flash has 284 billion total parameters but only 13 billion activate per inference. V4-Pro has 1.6 trillion total, 49 billion active.
The cost follows the active parameters, not the total. You are not paying for a 284B model. You are paying for a 13B inference cost while benefiting from knowledge that was trained across the full 284B. The routing mechanism is what makes this work. When the model sees a token, a learned gating layer decides which experts to activate. Different domains hit different expert subsets.
The practical implication: MoE models can be cheaper to serve than equivalently capable dense models. DeepSeek V4’s pricing is not a loss leader. It reflects the real compute cost of running 13B active parameters rather than a dense 100B+ model.
One Line Migration
I was skeptical about “drop-in compatible” until I tested it against topr.io, where we were already running Claude SDK calls. The change was exactly as advertised.
# before
base_url = "https://api.anthropic.com"
model = "claude-opus-4-5"
# after
base_url = "https://api.deepseek.com"
model = "deepseek-v4-pro"
Tool calls, function definitions, system prompts, message formats: all of them carry over. The endpoint speaks the same Anthropic protocol. Same SDK, same workflow. For OpenAI SDK users, the same base URL change applies. LangChain works without modification.
The migration risk is model behavior, not integration compatibility. DeepSeek V4 and Claude Opus 4 are different models with different failure modes. Any migration should run a regression pass on your production task set before switching fully. But the integration side is genuinely one line.
Building an Agent Router With V4
The pattern I use for mixed-model agentic systems: a router function that selects Flash or Pro based on the incoming task type, with a fallback escalation if Flash fails.
Step 1 is classifying the task before routing it. Extraction, summarization, tool-result parsing, and anything with a template-like output profile: Flash. Multi-step planning, complex code generation, ambiguous requirements, and anything where you need sustained reasoning across many steps: Pro.
Step 2 is setting up the context ordering deliberately. System prompt first. Static reference data next. Dynamic content last. This maximizes cache hits on the static portions.
Step 3 is monitoring cache hit rates in the usage object. DeepSeek returns this in the response. If a workload with a static system prompt is getting below 80% cache hits, the context ordering is wrong. Log it. Fix it.
Step 4 is using the 1M window to simplify retrieval. For document-heavy tasks, loading the full document is often more reliable and cheaper than a retrieval step that introduces its own error rate. V4’s Engram architecture earns its keep here.
The full blog post with the Python setup code and a worked example of the cache hit optimization is at https://buildthisnow.com/blog/models/deepseek-v4-pricing-context-migration.
메타데이터
- post_id
- ef8243faeb98
- slug
- deepseek-v4-pricing-context-and-migration-ef8243faeb98
- url
- https://medium.com/@hugues.bouiss/deepseek-v4-pricing-context-and-migration-ef8243faeb98
- canonical_url
- https://medium.com/@hugues.bouiss/deepseek-v4-pricing-context-and-migration-ef8243faeb98
- author_url
- https://medium.com/@hugues.bouiss
- status
- ok
- fetched_at
- 2026-06-09 15:37:30