DeepSeek Token Counter: How to Measure Prompt Size and API Cost

You are about to send a 30,000-word legal contract to deepseek-v4-pro: will it fit in the context window, and what will the round trip cost? A DeepSeek token counter answers the first question and the input side of the second; the output side depends on how long the reply, reasoning included, runs. The counter on this page gives an approximate, client-side token estimate plus the text’s input cost on deepseek-flash and deepseek-v4-pro. DeepSeek’s offline tokenizer gives a closer count, and the API’s usage block the exact, billed one. This guide covers all three and turns the numbers into dollars on deepseek-flash (DeepSeek-V4.1-Flash-1017) and deepseek-v4-pro (DeepSeek-V4-Pro-0813), at peak and off-peak rates.
What a DeepSeek token counter actually counts

DeepSeek Token Counter
Estimate token count and input cost before you send a request — paste text or code, or open a local file (it stays in your browser). Handles English, code and CJK text.
Structure
Cost of this text as input
| Model | Cache miss · peak | Cache miss · off-peak | Cache hit · peak | Cache hit · off-peak |
|---|---|---|---|---|
| deepseek-flash | $0 | $0 | $0 | $0 |
| deepseek-v4-pro | $0 | $0 | $0 | $0 |
What counts as a token, exactly?
Tokens are the units DeepSeek bills on. Its documentation gives rough ratios of about 0.3 tokens per English character and 0.6 tokens per Chinese character, and notes that the real count comes back in each API response's usage block. This tool uses a simpler heuristic: about 1.33 tokens per English word plus a little for punctuation, about one token per 3.5 characters for code-heavy text, and one token per Chinese, Japanese or Korean character — so it tends to overestimate Chinese text (DeepSeek's ratio is about 0.6 tokens per Chinese character) and is only a rough guess for Japanese and Korean. Use it for planning, not billing.
Prices from DeepSeek's official pricing page, last fetched 24 October 2026 (checked daily). Peak and off-peak rates as published there. Token counts are estimates; the usage block in API responses is authoritative for billing. Official pricing page ↗
The counter runs in your browser. It shows characters, words, sentences, lines, estimated tokens and the percentage of the 1M-token context window, and its “Cost of this text as input” table prices the text for deepseek-flash and deepseek-v4-pro in four columns: cache miss (peak), cache miss (off-peak), cache hit (peak) and cache hit (off-peak). It prices input only; for output, use the DeepSeek pricing calculator. Prices are fetched daily from DeepSeek’s official pricing page; the footnote shows the date of the last successful fetch.
The token figure is a heuristic, not a tokenizer (about 1.33 tokens per English word, one per CJK character), so it can read high or low, tends to overestimate Chinese text and is only a rough guess for Japanese and Korean. DeepSeek’s offline tokenizer counts the raw text with DeepSeek’s own tokenizer files but without the chat formatting the API adds; the API’s usage block is the billed count.
Tokens are the chunks of text the model reads and the unit DeepSeek bills on. DeepSeek’s Token & Token Usage page (22 October 2026) says a Chinese word, an English word, a number or a symbol typically counts as one token, with approximate ratios of 1 English character ≈ 0.3 token and 1 Chinese character ≈ 0.6 token. It adds that ratios vary by tokenizer and that the real count is the one the API returns: estimate before sending, reconcile after. Images sent to deepseek-flash count too, up to 1,024 tokens each (Vision guide, 22 October 2026); this counter counts text, not images.
There are two reasons to count before you call:
- Fit checking. Both models have a 1M-token context length and a maximum output of 384K tokens (pricing page; 393,216 per the API reference). Input plus output must fit, and at a limit, generation stops with
finish_reason“length”. - Cost forecasting. Output costs $1.20 / $0.60 per 1M tokens (peak / off-peak) on
deepseek-flashand $3.96 / $1.98 ondeepseek-v4-pro(pricing page, 22 October 2026), so Pro costs 3.3× Flash on output and 4.4× on cache-miss input, at either period.
The ways to count DeepSeek tokens
The right tool depends on whether you are sketching a prompt, scripting a batch job, or auditing a finished bill:
| Method | Best for | Accuracy | What you need |
|---|---|---|---|
| This page’s token counter (client-side estimate) | Quick sizing; input cost at peak and off-peak on both models | Approximate heuristic, high or low | A browser |
| DeepSeek’s offline demo tokenizer | Pre-flight checks in code, batch sizing | Raw-text count with DeepSeek’s tokenizer files; no chat formatting | Python and transformers |
Hugging Face tokenizer for the model you call: deepseek-ai/DeepSeek-V4.1-Flash-1017 (deepseek-flash) or deepseek-ai/DeepSeek-V4-Pro-0813 (deepseek-v4-pro) |
Full chat prompts, via the repo’s encoding script | Close estimate; template or server handling can differ | Python and the repo’s files |
| Third-party web counters | Paste-and-check on one prompt | Approximate; may not use DeepSeek’s current tokenizer | A browser |
API usage response field |
Billing reconciliation | Authoritative — this is what you pay for | An API key; one billed request |
1. The official offline tokenizer
DeepSeek’s Token & Token Usage page offers a downloadable demo tokenizer (deepseek_tokenizer.zip, 22 October 2026): tokenizer files plus a short transformers script that encodes a plain string, without chat formatting. Use it in CI to flag prompts that drift past a threshold. For whole chat requests, this snippet, adapted from the DeepSeek-V4-Pro-0813 model card example (fetched 22 October 2026), estimates the prompt-side count for deepseek-v4-pro:
# Needs encoding/encoding_dsv4.py from deepseek-ai/DeepSeek-V4-Pro-0813 (not on pip).
from transformers import AutoTokenizer
from encoding_dsv4 import encode_messages
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-V4-Pro-0813")
messages = [
{"role": "system", "content": "You are a careful legal assistant."},
{"role": "user", "content": "Summarise this contract: ..."},
]
# Mirrors the API defaults (thinking on, effort "high"); use "chat" if thinking is off.
prompt = encode_messages(messages, thinking_mode="thinking", reasoning_effort="high")
print(len(tokenizer.encode(prompt)))
Instead of a Jinja chat template, the release ships a Python encoding folder (model card). In the -0813 encoder, the "high" and "max" efforts add a prompt prefix, and the encoder’s default is "low" (no prefix), unlike the API’s "high", so pass the effort explicitly.
For deepseek-flash, use deepseek-ai/DeepSeek-V4.1-Flash-1017, named in DeepSeek’s 17 October 2026 release note (checked 22 October 2026). It ships its own tokenizer.json and encoding/encoding.py (from encoding import encode_messages), and its encoding/README.md lists prompt-format changes from V4 (DSML tag spacing, a numeric effort prefix, a <|System|> token), so swapping the model ID above does not reproduce its prompts. For the surrounding plumbing, see the DeepSeek Python integration tutorial.
2. Web-based DeepSeek token counters
Browser counters suit one-off drafting, with two caveats: third-party tools may not use DeepSeek’s current tokenizer files (deepseek-flash has been DeepSeek-V4.1-Flash-1017 since 17 October 2026), and raw-text counters omit the role and special tokens the chat format adds, which grow with each message. Treat any web estimate, ours included, as approximate in either direction.
3. The authoritative number — the API usage field
Chat requests hit POST /chat/completions at https://api.deepseek.com, and every response carries a usage block, the source of truth for billing. DeepSeek’s API reference (22 October 2026) lists seven fields:
prompt_tokens— total input; equals prompt_cache_hit_tokens + prompt_cache_miss_tokens.prompt_cache_hit_tokens— input served from the context cache (cheaper rate).prompt_cache_miss_tokens— input that missed it (full rate).prompt_tokens_details.cached_tokens— the same asprompt_cache_hit_tokens.completion_tokens— output tokens.completion_tokens_details.reasoning_tokens— output tokens spent on reasoning, whose text arrives asreasoning_content. Thinking is the default, so expect these unless you disable it; they are billed at the output rate for the period.total_tokens— prompt plus completion.
Log the full breakdown, not just total_tokens, or you lose the cache-hit signal that explains your bill.
4. Python: parse usage on every call
A minimal logging helper with the OpenAI SDK; as in DeepSeek’s samples, the key comes from DEEPSEEK_API_KEY, and thinking is set explicitly:
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ.get("DEEPSEEK_API_KEY"), base_url="https://api.deepseek.com")
resp = client.chat.completions.create(
model="deepseek-flash",
messages=[{"role": "user", "content": "Hello"}],
reasoning_effort="high",
extra_body={"thinking": {"type": "enabled"}},
)
u = resp.usage
print({
"prompt_tokens": u.prompt_tokens,
"cache_hit": u.prompt_cache_hit_tokens,
"cache_miss": u.prompt_cache_miss_tokens,
"completion_tokens": u.completion_tokens,
"reasoning_tokens": getattr(u.completion_tokens_details, "reasoning_tokens", None),
"total": u.total_tokens,
})
See the DeepSeek API documentation for every field, and the DeepSeek Node.js integration guide for the same pattern in JavaScript.
From token count to dollar cost
The math is mechanical. As of 22 October 2026, DeepSeek’s official pricing page lists (USD per 1M tokens, peak / off-peak):
| Model | Input cache hit | Input cache miss | Output |
|---|---|---|---|
| deepseek-flash (DeepSeek-V4.1-Flash-1017) | $0.006 / $0.003 | $0.30 / $0.15 | $1.20 / $0.60 |
| deepseek-v4-pro (DeepSeek-V4-Pro-0813) | $0.044 / $0.022 | $1.32 / $0.66 | $3.96 / $1.98 |
Off-peak rates are half the peak rates (since 16:00 UTC on 16 August 2026). Peak hours are 01:00–04:00 and 06:00–10:00 UTC, Monday to Friday, excluding Chinese public holidays; all other hours are off-peak. Per bucket, cost = tokens ÷ 1,000,000 × rate; sum the buckets at peak and again at off-peak rates. DeepSeek says prices may vary and that it reserves the right to adjust them; this site’s tools re-read the official DeepSeek pricing page daily and show the last fetch date.
Worked example A — deepseek-flash, 1M calls a day (illustrative)
Illustrative arithmetic, not a measurement: 1,000,000 calls a day, each with a 2,000-token system prompt assumed to hit the cache every time, a 200-token user message (cache miss) and 300 output tokens, reasoning included (thinking is on by default). Real hit rates can be lower, since DeepSeek calls its cache best-effort. Totals: 2,000 × 1,000,000 = 2,000,000,000 cached tokens; 200 × 1,000,000 = 200,000,000 uncached; 300 × 1,000,000 = 300,000,000 output.
- Cached input: 2,000,000,000 ÷ 1,000,000 × $0.006 = $12.00 peak; × $0.003 = $6.00 off-peak
- Uncached input: 200,000,000 ÷ 1,000,000 × $0.30 = $60.00 peak; × $0.15 = $30.00 off-peak
- Output: 300,000,000 ÷ 1,000,000 × $1.20 = $360.00 peak; × $0.60 = $180.00 off-peak
- Total: $432.00 a day at peak rates, $216.00 off-peak ($0.000432 and $0.000216 per call)
Worked example B — deepseek-v4-pro, same workload (illustrative)
- Cached input: 2,000,000,000 ÷ 1,000,000 × $0.044 = $88.00 peak; × $0.022 = $44.00 off-peak
- Uncached input: 200,000,000 ÷ 1,000,000 × $1.32 = $264.00 peak; × $0.66 = $132.00 off-peak
- Output: 300,000,000 ÷ 1,000,000 × $3.96 = $1,188.00 peak; × $1.98 = $594.00 off-peak
- Total: $1,540.00 a day at peak rates, $770.00 off-peak ($0.00154 and $0.00077 per call)
Here deepseek-v4-pro costs about 3.56× deepseek-flash at either period ($1,540.00 ÷ $432.00 and $770.00 ÷ $216.00 both give 3.5648…, rounded to two decimals); all other figures are exact.
Do not skip the uncached-input line: only a prefix DeepSeek has already persisted (here, the system prompt) can hit the cache, and only on a full match (Context Caching guide, 22 October 2026). Price peak and off-peak separately, or blend them on purpose by your share of peak-hour traffic. The DeepSeek pricing calculator shows peak and off-peak totals side by side for one model or both, and the DeepSeek cost estimator projects them per request, day, month and year, plus a blend.
Counting tokens for thinking mode
On both models, thinking mode is on by default with effort "high" (Thinking Mode guide, 22 October 2026). With the OpenAI SDK, set it with extra_body={"thinking": {"type": "enabled"}} and reasoning_effort="high" (or low / max); turn it off with extra_body={"thinking": {"type": "disabled"}}. temperature, presence_penalty and frequency_penalty have no effect in thinking mode. The trace returns in reasoning_content and is billed at the output rate for the period (table above).
Two implications for counting:
- Reserve output budget. For long reasoning, set
max_tokensexplicitly (up to 384K); unset, it defaults to 8K in non-thinking mode, 64K in thinking mode and 128K atmaxeffort (API reference, 22 October 2026). - Watch
completion_tokens_details.reasoning_tokens. DeepSeek suggestslowfor simple tasks,highfor everyday agent tasks andmaxfor complex ones (Change Log, 13 August 2026); if trivial requests spend many reasoning tokens, disable thinking or uselowfor them.
deepseek-chat and deepseek-reasoner were retired after 15:59 UTC on 24 July 2026; until then they routed to deepseek-v4-flash in non-thinking and thinking mode. deepseek-v4-flash and deepseek-v4-flash-vision-exp are still accepted but retired; their requests are served by DeepSeek-V4.1-Flash-1017 at the Flash price. Switching to deepseek-flash is a one-line model= change with the same base_url; if you relied on non-thinking behaviour, disable thinking. The DeepSeek context caching guide explains how prefix reuse interacts with token counting.
Common counting mistakes

- Using a GPT tokenizer for DeepSeek. DeepSeek notes that token-to-character ratios can vary with each model’s tokenization method (Token & Token Usage page, 22 October 2026), so a GPT count is only an approximation for DeepSeek.
- Forgetting chat template overhead. Roles, special tokens and separators cost tokens, and the overhead grows with each message, tool definitions and effort prefixes.
- Ignoring the cache split. Log only
total_tokensand you cannot tell long prompts from caching that is not landing. - Ignoring peak vs off-peak. Off-peak is half the peak rate, so pricing off-peak traffic at peak rates doubles its estimate, and the reverse halves it.
- Forgetting that thinking is the default. Unless you disable it, thinking adds reasoning tokens, billed as output.
- Mixing model rates. Costing a
deepseek-v4-proworkload atdeepseek-flashrates understates output cost by a factor of 3.3 (4.4 on cache-miss input). - Skipping
max_tokenswith JSON mode. The API reference says JSON Output “guarantees the message the model generates is valid JSON”, but content can be cut off atfinish_reason“length”; the JSON Output guide advises “json” plus an example in the prompt and a sensiblemax_tokens, and warns of occasional empty content (22 October 2026).
For more on the surrounding plumbing — auth, rate limits, JSON mode caveats — see the DeepSeek tools and utilities hub and the DeepSeek API best practices guide.
A practical workflow
- Draft the prompt in any text editor.
- Paste it into the token counter above for a quick estimate and its peak and off-peak input cost; for a closer count, use DeepSeek’s offline tokenizer or your model’s Hugging Face tokenizer (DeepSeek-V4.1-Flash-1017 or DeepSeek-V4-Pro-0813).
- Project cost with your model’s peak and off-peak rates (or a blend matching when your traffic runs) and an expected output size, reasoning included.
- Send a single real call; capture the full
usageblock. - Reconcile estimate vs actual; tune your forecasting multiplier.
Repeat this for each prompt template so your forecasting multiplier reflects real usage.
DeepSeek AI Guide is an independent resource and is not affiliated with DeepSeek or its parent company. Model IDs, pricing and API behaviour change; check the official DeepSeek documentation and pricing page before committing to a production decision.
How do you count tokens for DeepSeek before sending a prompt?
Paste the text into the counter on this page for a quick, approximate estimate and its peak and off-peak input cost. For a closer count, use DeepSeek’s offline demo tokenizer (Token & Token Usage page) or your model’s Hugging Face tokenizer and encoding script (deepseek-ai/DeepSeek-V4.1-Flash-1017 or deepseek-ai/DeepSeek-V4-Pro-0813). The API usage block is authoritative; the DeepSeek API documentation covers the response shape.
What does the usage block return on a DeepSeek API call?
Every POST /chat/completions response includes prompt_tokens, prompt_cache_hit_tokens, prompt_cache_miss_tokens, prompt_tokens_details.cached_tokens (the same as the cache-hit count), completion_tokens, total_tokens, plus completion_tokens_details.reasoning_tokens when thinking is on (the default). The DeepSeek context caching guide explains how prefix reuse drives the hit/miss ratio.
Is one DeepSeek token the same as one word?
Not exactly; the ratio shifts by language and content. DeepSeek’s documentation gives approximate ratios of 0.3 tokens per English character (about 3.3 characters per token) and 0.6 per Chinese character (22 October 2026); the exact figure is the usage block returned by the API. The DeepSeek token limits guide expands on context length specifics.
Does the DeepSeek token counter work for deepseek-flash and deepseek-v4-pro?
Yes. It estimates tokens for any pasted text and prices it as input on both models, as a cache miss or hit, at peak and off-peak rates, with prices fetched daily from DeepSeek’s official pricing page (the footnote shows the last fetch date). It is an estimate; the API usage block is exact. Both models have a 1M-token context and up to 384K output tokens (pricing page, 22 October 2026). See DeepSeek V4 for an overview of the model family.
How do you turn token counts into a dollar estimate?
Use the rate card for your model and period. deepseek-flash: $0.006 / $0.003 cache hit, $0.30 / $0.15 cache miss, $1.20 / $0.60 output per 1M tokens (peak / off-peak, as of 22 October 2026). deepseek-v4-pro: $0.044 / $0.022, $1.32 / $0.66 and $3.96 / $1.98. Off-peak has been half the peak rate since 16 August 2026; peak is 01:00–04:00 and 06:00–10:00 UTC, Monday to Friday, excluding Chinese public holidays. Per bucket, cost = tokens ÷ 1,000,000 × rate; add the buckets once at peak and once at off-peak rates. The DeepSeek pricing calculator automates the math for both models.
Sources & Methodology
Primary sources
- PricingOfficial DeepSeek pricing pagedeepseek-flash (DeepSeek-V4.1-Flash-1017) and deepseek-v4-pro (DeepSeek-V4-Pro-0813) peak and off-peak rates, peak hours, 1M context, 384K max output, legacy deepseek-v4-flash names served at the Flash price, and DeepSeek's note that prices may change (fetched 22 October 2026)Last checked: October 22, 2026
- DocumentationDeepSeek Token & Token Usage pageOfficial character-to-token ratios, downloadable demo tokenizer (deepseek_tokenizer.zip) and the statement that the API's usage is the actual count (fetched 22 October 2026)Last checked: October 22, 2026
- DocumentationDeepSeek API docs: Your First API Callbase_url https://api.deepseek.com and the deepseek-flash / deepseek-v4-pro model names; sample code that reads the key from DEEPSEEK_API_KEY and sets thinking explicitly (fetched 22 October 2026)Last checked: October 22, 2026
Technical references
- DocumentationDeepSeek API reference: Chat CompletionsThe seven usage fields; max_tokens range 1 to 384K (393,216) and its 8K / 64K / 128K defaults; finish_reason "length"; JSON Output guarantee (fetched 22 October 2026)Last checked: October 22, 2026
- DocumentationDeepSeek Thinking Mode guideThinking on by default (effort high); extra_body thinking toggle; low / high / max efforts; temperature and penalties ignored in thinking mode (fetched 22 October 2026)Last checked: October 22, 2026
- DocumentationDeepSeek Context Caching guideBest-effort disk cache; a request hits only on a full match of a persisted prefix unit (fetched 22 October 2026)Last checked: October 22, 2026
- DocumentationDeepSeek JSON Output guideJSON Output prompt requirements, max_tokens advice, occasional empty content (fetched 22 October 2026)Last checked: October 22, 2026
- DocumentationDeepSeek Vision guideImages sent to deepseek-flash billed as tokens, up to 1,024 per image (fetched 22 October 2026)Last checked: October 22, 2026
- Model cardDeepSeek-V4-Pro-0813 model card (Hugging Face)encode_messages example adapted for the tokenizer snippet; encoding/encoding_dsv4.py thinking_mode values and low / high / max effort prefixes (fetched 22 October 2026)Last checked: October 22, 2026
- Model cardDeepSeek-V4.1-Flash-1017 model card (Hugging Face)Own tokenizer.json and encoding/encoding.py for deepseek-flash; V4.1 prompt-format changes listed in its encoding/README.md (fetched 22 October 2026)Last checked: October 22, 2026
Context sources
- Change logDeepSeek API Change Logdeepseek-chat / deepseek-reasoner retirement on 2026-07-24 (24 Apr 2026 entry); effort-level guidance and peak/off-peak pricing from 16:00 UTC, 16 Aug 2026 (13 Aug 2026 entry); V4-Flash retired (10 Sep 2026); DeepSeek-V4.1-Flash-1017 (17 Oct 2026)Last checked: October 22, 2026
- NewsDeepSeek news: DeepSeek V4 Preview Release (24 Apr 2026)deepseek-chat / deepseek-reasoner fully retired after 15:59 UTC, 24 Jul 2026; routed to deepseek-v4-flash non-thinking / thinking until thenLast checked: October 22, 2026
- NewsDeepSeek news: DeepSeek-V4.1-Flash-1017 (17 Oct 2026)Hugging Face repository named for the DeepSeek-V4.1-Flash-1017 open weightsLast checked: October 22, 2026
Methodology
Facts and prices come from DeepSeek's official documentation, pricing page and Hugging Face model cards as checked on 22 October 2026. Worked examples are illustrative arithmetic, the on-page token counter is a heuristic estimate, and the site does not run its own evaluations or tests.
Data confidence
High for facts cited inline with primary-source links; medium for context narrative.
Editorial note
AI tooling moves quickly. If you spot an outdated number or a broken link, the contact link in the footer is the fastest way to flag it for the editorial team.
