DeepSeek V4 · Published tokenizer

DeepSeek V4 Token Counter

Count base-text tokens for DeepSeek V4 Pro and DeepSeek V4 Flash with the tokenizer published alongside the open model weights.

Accuracy note

Exact base-text tokenizer output from the published DeepSeek V4 tokenizer. Chat templates, provider wrappers, tools, media, and reasoning usage can add tokens to a complete request.

Models
deepseek-v4-pro · deepseek-v4-flash
Context
1,048,576 tokens
Maximum output
384K tokens
Local support
Exact base-text tokenizer

Facts checked against official sources on .

How to Count DeepSeek V4 Tokens

For raw text, use the tokenizer published with the exact DeepSeek V4 checkpoint. Tiktokenizer loads that tokenizer in the browser and exposes the resulting token boundaries and IDs. DeepSeek V4 Pro and V4 Flash are released as one model family and use the same model-specific counting workflow.

For a complete API request, treat the provider's usage response as authoritative. A serving stack can apply a chat template, insert role markers and special tokens, serialize tool definitions, or account for reasoning and cache usage beyond the text pasted into a local counter.

pythonOfficial counting example
from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(
    "deepseek-ai/DeepSeek-V4-Flash"
)
text = "Count this DeepSeek V4 prompt."
token_ids = tokenizer.encode(text, add_special_tokens=False)
print(len(token_ids), token_ids)

DeepSeek V4 Pro vs V4 Flash Token Counting

The Pro and Flash variants differ in model size, capability, speed, and price, but token counting should still be tied to the published V4 tokenizer and the request template used by your inference provider. You do not need to estimate V4 tokens with an OpenAI encoding.

The current DeepSeek API lists a 1M-token context and a maximum output of 384K tokens for both variants. It identifies the current Flash service version as DeepSeek-V4-Flash-0731.

VariantAPI model IDContext windowRecommended count
DeepSeek V4 Prodeepseek-v4-pro1,048,576Published V4 tokenizer + API usage
DeepSeek V4 Flashdeepseek-v4-flash1,048,576Published V4 tokenizer + API usage

What the Local DeepSeek Count Includes

  • The token IDs produced from the exact text entered in the browser.
  • Model-specific vocabulary and pre-tokenization behavior from the published tokenizer.
  • No automatic guarantee that a third-party inference provider uses an identical chat template.
  • No hidden reasoning, tool-call, cache, image, or generated-output usage.

DeepSeek V4 Migration Note

DeepSeek announced the V4 preview on April 24, 2026, and the legacy deepseek-chat and deepseek-reasoner names became inaccessible after July 24, 2026 at 15:59 UTC. Applications should use the explicit deepseek-v4-pro or deepseek-v4-flash model ID and recount representative prompts under the V4 request format.

Do not reuse a DeepSeek R1 count as a V4 billing or context guarantee. Even when two model generations produce similar raw-text results, a changed tokenizer configuration or serving template can alter the complete request.

Tiktokenizer Reference Sources

Tokenizer behavior and model limits change. Verify production decisions with current provider documentation:

Frequently asked questions

Do DeepSeek V4 Pro and Flash use the same tokenizer workflow?

Yes. Use the published tokenizer for the V4 checkpoint, then verify complete structured requests with the usage returned by your inference provider.

Is this DeepSeek V4 count exact?

It is exact for base text under the published tokenizer. Chat templates, tools, reasoning, media, and provider wrappers can change complete request usage.

Does DeepSeek V4 have a one-million-token context window?

DeepSeek documents a 1,048,576-token context window for the V4 family.

Can I use an OpenAI tokenizer for DeepSeek V4?

Not for an authoritative count. Use the DeepSeek V4 tokenizer because different vocabularies can split the same text differently.