Back to All Cheatsheet Libraries cheatsheets

DeepSeek

Model lineup, reasoning mode, and open-weight/API reference for DeepSeek.

The price is the headline

DeepSeek's models are competitive on capability, but what makes them worth knowing is cost: roughly an order of magnitude cheaper than frontier models from the large US labs, with a 1M-token context window and an OpenAI-compatible API.

Two mechanisms push that further — context caching, where a repeated prefix costs about 3% of a fresh one, and off-peak pricing at half rate. Used together they change what's economically viable for bulk work.

Model Cache hit / M Cache miss / M Output / M Concurrency
deepseek-v4-flash$0.007–$0.014$0.22–$0.44$0.66–$1.322500
deepseek-v4-pro$0.022–$0.044$0.66–$1.32$1.98–$3.96500
deepseek-v4-flash-vision-exp$0.007–$0.014$0.22–$0.44$0.66–$1.322500

Lower figure is off-peak, higher is peak. All three models: 1M context, 384K max output.

Which model
  • deepseek-v4-flash — the default. Currently DeepSeek-V4-Flash-0731. Cheapest, and 2500 concurrency makes it the one for bulk work.
  • deepseek-v4-pro — currently DeepSeek-V4-Pro-0813. Roughly 3× the price of flash, and 500 concurrency — that lower ceiling matters more than the price for high-throughput jobs.
  • deepseek-v4-flash-vision-exp — experimental, additionally accepts image input, priced as flash.
  • The named aliases point at dated snapshots that get updated. That means output can change under you without any change on your side.
  • Thinking mode is a request parameter rather than a separate model — you toggle reasoning on the same endpoint.
Peak and off-peak
  • Peak hours: 01:00–04:00 and 06:00–10:00 UTC. Everything outside those windows bills at half the peak rate.
  • From 23 August 2026, off-peak rates apply all day on Saturdays and Sundays (Beijing time).
  • For batch jobs that don't need to run now, scheduling them off-peak halves the bill for zero engineering effort.
  • Note the peak windows are defined in UTC while the weekend rule is Beijing time — check both against your own schedule.

Compatible with both OpenAI and Anthropic formats

Unusually, DeepSeek exposes two compatible surfaces. If you already have code written against either SDK, you change the base URL and the key.

# OpenAI format from openai import OpenAI client = OpenAI( api_key=os.environ["DEEPSEEK_API_KEY"], base_url="https://api.deepseek.com", ) resp = client.chat.completions.create( model="deepseek-v4-flash", messages=[ {"role": "system", "content": "You are a precise technical assistant."}, {"role": "user", "content": "Explain B-tree indexes briefly."}, ], temperature=0.2, ) print(resp.choices[0].message.content) # Anthropic format — same service, different surface # base_url="https://api.deepseek.com/anthropic" # Streaming stream = client.chat.completions.create( model="deepseek-v4-flash", messages=[{"role": "user", "content": "List 5 index types."}], stream=True, ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="") # curl curl https://api.deepseek.com/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DEEPSEEK_API_KEY" \ -d '{ "model": "deepseek-v4-flash", "messages": [{"role": "user", "content": "Summarise in one line."}], "stream": false }'
Practical notes
  • Base URL is https://api.deepseek.com for the OpenAI shape, https://api.deepseek.com/anthropic for the Anthropic one.
  • Note there's no /v1 in the OpenAI base URL — a common first-request 404.
  • Max output is 384K tokens, which is far larger than most providers allow; you can genuinely ask for a long document in one call.
  • Reasoning is enabled per request via the thinking parameter rather than by switching model.
  • Keys are server-side only. Never ship one in a browser bundle.
  • Handle 429s with backoff — concurrency limits differ sharply between flash (2500) and pro (500).

Context caching is the big lever

A cache hit costs roughly 3% of a cache miss — $0.007 against $0.22 per million on flash. If your requests share a long prefix, structuring for cache hits is the single highest-return optimisation available.

It's automatic, but only if you build the prompt so the shared part is genuinely identical and comes first.

1

Put the stable content first

System prompt, instructions, schemas, reference documents, few-shot examples — all at the front, byte-identical across requests. Caching matches on prefix.

2

Put the variable content last

The user's actual question goes at the end. One changed character near the start invalidates the whole cached prefix.

✅ [long stable system prompt][reference docs][user question] ❌ [user question][long stable system prompt][reference docs] ❌ [system prompt with a timestamp in it][docs][question] ← never hits
3

Strip anything that varies pointlessly

Timestamps, request IDs, and randomised example ordering inside an otherwise-stable prefix silently destroy the cache. This is the most common reason a hit rate is near zero.

4

Check your hit rate

The response usage object reports cached versus uncached input tokens. Measure it — assuming caching works is how people end up paying full price for months.

5

Then schedule off-peak

Half price outside 01:00–04:00 and 06:00–10:00 UTC, and all weekend from 23 August 2026. Caching and off-peak stack.

Where the money actually goes
  • Output is the expensive side — $0.66–$1.32 per million on flash against $0.22–$0.44 for uncached input. Constrain response length rather than obsessing over prompt size.
  • Ask for structured output and cap it. "Answer in under 100 words" is a real cost control.
  • Reasoning tokens count as output. Enable thinking mode only where it earns its keep.
  • A 1M context window is an option, not an instruction — sending 1M tokens because you can is expensive and dilutes attention.
  • Use flash by default and reserve pro for tasks that measurably need it. Benchmark on your own workload rather than assuming.

Gotchas

Data residency and governance — decide this first
  • DeepSeek is a Chinese company and the API is hosted in China. Your prompts leave your jurisdiction and are subject to Chinese law.
  • For many organisations that alone rules it out for customer data, personal data, or anything regulated. Check with whoever owns your data policy before piloting it, not after.
  • Read the current retention and training-use terms — whether prompts may be used for training is a material question and the answer can change.
  • The models are also open-weight, so self-hosting is a genuine alternative if the API's jurisdiction is the blocker but the capability is wanted. That moves the data question entirely into your own infrastructure.
  • Expect the models to decline or deflect on topics politically sensitive in China. That's a real functional constraint, not a bug you can prompt around.
Other things worth knowing
  • No /v1 in the base URL. https://api.deepseek.com — the reflexive addition causes a 404 on the first call.
  • Model aliases point at dated snapshots that are updated in place, so behaviour can shift without any change on your side. Evaluate after any announced update.
  • Peak hours are UTC but the weekend off-peak rule is Beijing time. Mixing them up will cost you.
  • The 500 concurrency ceiling on pro is often the real constraint on throughput, not price.
  • Cache hit rates collapse silently if anything variable creeps into the prefix. Monitor rather than assume.
  • Latency from outside China is meaningfully higher than from a local provider — worth measuring for interactive use.
  • Prices here are a snapshot. DeepSeek has changed pricing structure repeatedly; check the live page.

Tips

Engineer for cache hits

Stable prefix first, variable content last, nothing random in between. At 3% of the miss price this is the highest-leverage change you can make.

Batch off-peak

Anything that doesn't need to run immediately should run outside 01:00–04:00 and 06:00–10:00 UTC. Half price for a cron change.

Two compatible surfaces

OpenAI and Anthropic formats are both supported, so whichever SDK you already use, migration is a base-URL change.

Cap the output

Output costs ~3× uncached input. Length limits and structured formats do more for your bill than prompt trimming.

Self-host if jurisdiction blocks you

Open weights mean you can run the models on your own infrastructure — the usual answer when the capability is wanted but the hosted API isn't permitted.

Measure, don't assume

Check cached-token counts in the usage object and benchmark flash against pro on your own workload. Both defaults are frequently wrong.

Resources