Kimi K3 · Exact base-text tokenizer

Kimi K3 Token Counter

Count raw Kimi K3 text locally with its published 160K vocabulary, inspect token boundaries, and understand when the full XTML encoder or Kimi API usage is required.

Accuracy note

Exact for ordinary base text under a browser-compatible conversion of Kimi K3's published vocabulary. K3's Python XTML message encoder, special control tokens, tools, images, video, and provider wrappers are not added automatically; use the complete encoder or Kimi API usage for full requests.

API model ID
kimi-k3
Context
1,048,576 tokens
Vocabulary
160K tokens
Local support
Exact ordinary base text

Facts checked against official sources on .

How to Count Kimi K3 Tokens

Kimi K3 is now open-weight and its official repository publishes a 160K token vocabulary plus a custom Python tokenizer and XTML message encoder. Tiktokenizer loads a browser-compatible tokenizer conversion derived from those artifacts, so ordinary text entered above is counted with K3 token IDs rather than an o200k_base comparison.

For a complete chat request, ordinary text is only one layer. Kimi K3 uses XTML structural markers for messages, thinking, tools, and responses, and it has model-specific handling for images and other media. Use Moonshot's published tokenizer with trust_remote_code=True or the Kimi API when you need the complete serialized request rather than a raw-text count.

pythonOfficial counting example
from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(
    "moonshotai/Kimi-K3",
    trust_remote_code=True,
)
text = "Count this Kimi K3 prompt."
token_ids = tokenizer.encode(text, add_special_tokens=False)
print(len(token_ids))
print(token_ids)

Kimi K3 Local Count vs Full Request Usage

The browser counter is appropriate for inspecting prose, Chinese text, source code, JSON, whitespace, and other ordinary text. It does not execute arbitrary Python from the model repository, and it does not attempt to simulate image or video token accounting.

The converted tokenizer has been validated against K3's custom tokenizer for ordinary encoding, but Kimi's custom Python chat renderer remains the reference for XTML conversation structure. The usage returned by a real kimi-k3 API call remains authoritative for provider billing.

Counting methodStatusUse it for
Tiktokenizer K3 browser tokenizerExact ordinary textToken boundaries, IDs, and raw text size
Official K3 Python tokenizer + XTML encoderReference implementationMessages, thinking, tools, and special tokens
Kimi API usageProvider-authoritativeReal multimodal request usage and billing review

Kimi K3 Model and Context Facts

Moonshot describes Kimi K3 as an open-weight, native multimodal agentic model for long-horizon coding, knowledge work, and reasoning. The published model has 2.8 trillion total parameters, 104 billion activated parameters, a 160K vocabulary, and a 1,048,576-token context window.

The Kimi API model ID is kimi-k3. Thinking is always enabled for K3, with low, high, and max reasoning-effort settings and max as the documented default. Native visual and video inputs are supported by the API, but their usage should be read from the API rather than inferred from the text vocabulary.

  • System and user messages, prior turns, and any preserved reasoning content sent back to the model.
  • Tool definitions and tool results used by a long-running coding or research agent.
  • Text, images, and video inputs, which do not all follow plain-text tokenization.
  • Expected reasoning and final-answer output, because Kimi K3 reasons by default.

Why the Kimi K3 API Count Can Be Higher

A Kimi API request wraps content in the K3 message format and can include system messages, XTML control tokens, reasoning content, tools, images, videos, and prior assistant messages. Those components can increase usage even when the visible user sentence has the same base-text count.

For multi-turn conversations and tool calls, Moonshot instructs clients to send the complete assistant message back on the next turn rather than keeping only its final content. Recount or inspect provider usage whenever the conversation history, tools, media, or reasoning effort changes.

Tiktokenizer Reference Sources

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

Frequently asked questions

Is the local Kimi K3 token count exact?

It is exact for ordinary base text under the converted K3 vocabulary. Complete XTML chats, tools, images, video, and provider formatting require the official encoder or Kimi API usage.

What is the Kimi K3 model ID?

The official API model ID is kimi-k3.

What is the Kimi K3 context window?

Moonshot documents a 1,048,576-token context window and a 160K-token vocabulary for Kimi K3.

Does Kimi K3 use tiktoken?

K3 publishes a custom TikTokenTokenizer and Python XTML encoder. Tiktokenizer uses a browser-compatible conversion of the same ordinary-text vocabulary.

Can this counter include images and video?

No. The local counter analyzes text. Read Kimi API usage for native image, video, and complete multimodal requests.