# Count Tokens in Multilingual Prompts Before Sending Them

> Measure the same UTF-8 prompt text with two tiktoken encodings and separate text-only counts from full API usage.

Canonical article: https://modelrovia.com/guides/count-multilingual-prompt-tokens/
Author: Modelrovia Editorial
Published: 2026-11-12
Updated: 2026-11-12

## Key takeaway

Compare local text counts for two named encodings.

A token budget depends on the exact text and the encoding used to read it. Before rewriting a Chinese or English prompt to fit a limit, measure the version you actually plan to send. Byte length, word count and token count describe different properties of that text. [tiktoken library documentation](https://github.com/openai/tiktoken/blob/main/README.md)

## Count the same bytes with two encodings

Download the [counter](/examples/count-prompt-text-tokens.py), [English sentence](/examples/token-count-en.txt), [Chinese sentence](/examples/token-count-zh.txt) and [French sentence](/examples/token-count-fr.txt). Save these files in one folder and run them in a fresh Python environment.

~~~sh
python -m pip install tiktoken==0.14.0
python count-prompt-text-tokens.py token-count-en.txt cl100k_base o200k_base
python count-prompt-text-tokens.py token-count-zh.txt cl100k_base o200k_base
python count-prompt-text-tokens.py token-count-fr.txt cl100k_base o200k_base
~~~

The first run may download encoding data. The script reads UTF-8 bytes directly, preserving spaces and line endings before tokenization. It treats the file as ordinary text, including any strings that resemble reserved token markers.

| Sample | UTF-8 bytes | cl100k_base | o200k_base |
| --- | --- | --- | --- |
| The export job has expired. | 27 | 6 | 6 |
| 导出任务已过期。 | 24 | 7 | 7 |
| La tâche d’export a expiré. | 31 | 12 | 9 |

The November 12, 2026 local run counted all three files with tiktoken 0.14.0. The Chinese sentence uses fewer bytes than the English one and one more token. The two encodings also assign different counts to the same French text. To estimate a workload, run it on representative prompts that include your actual headings, identifiers, examples and target languages.

## Use the count for a specific decision

If a prompt is near your budget, measure the full text before and after removing an example. Token boundaries can shift when pieces are joined, so count the final string rather than adding independent section counts. Record the encoding and keep that string with the measurement.

For a model request, choose the encoding documented for the model. The count here covers the contents of one text file. A provider can also count message framing, tool definitions and other inputs. Use the provider's returned usage to check the actual request, and keep room for the expected output and any model-specific allowances. Cache hit and miss counts are a further measurement made by the service. [DeepSeek context cache guide](/guides/deepseek-context-cache-misses/)

## Sources & references

- [tiktoken library documentation](https://github.com/openai/tiktoken/blob/main/README.md)

[Editorial standards](https://modelrovia.com/methodology/)
