[KongchangAI]
Product

tiktoken

A tokenization library developed by OpenAI, based on the Byte Pair Encoding (BPE) algorithm. It is used for text tokenization in models such as ChatGPT.

Core Facts

Timeline (last 90 days)

Oct 19

The project provides a free counter at modelmarket.dev/tools/tool-list-cost that uses the same tokenizer as the statistics and was compared against tiktoken on 120 of HISTOR's tool lists (2.6 million tokens in total), with zero differences.

Unverified50%
Oct 19

tiktoken is OpenAI's open-source tokenizer library, and cl100k_base is its commonly used encoding scheme; an English word typically corresponds to 1-2 tokens, while Chinese uses more.

Unverified50%
Oct 19

The OpenAI API's logit_bias parameter does not accept the word itself as a key but requires token ID strings, which must be obtained by encoding with the tokenizer matching the model (such as the tiktoken library).

Unverified50%
Oct 17

An LLM gateway needs to parse the model field in the request payload to make routing decisions, use tokenizers such as tiktoken to count tokens in messages for token-based rate limiting, translate OpenAI-format tools definitions into Anthropic's input_schema, and extract and accumulate the usage field from each chunk of the response stream to compute cost.

Unverified50%
Oct 16

The author's measurements show that the JSON Schema definitions of 18 tools consume 2,388 tokens, averaging 133 tokens per tool, and in a 10-step Agent run they can account for 36% of input tokens and 32% of the total bill.

Unverified50%
Oct 16

When counting with the tiktoken library and the o200k_base encoding, the smallest git_status tool (no parameters) is only 54 tokens, while the largest search_code tool (five parameters) reaches 193 tokens.

Unverified50%
Oct 13

tiktoken's README gives an average of about 4 bytes of text per token.

Unverified50%
Oct 13

OpenAI's tokenizer is open source; in JavaScript, js-tiktoken can run in any environment (including the browser), and in Python the corresponding package is tiktoken.

Unverified50%
Oct 13

tiktoken's encode raises an error when processing text containing special tokens, unless disallowed_special=() is passed.

Unverified50%
Oct 13

tiktoken is a compiled package and downloads vocabulary files, so it is not always suitable for lightweight libraries, network-free CI environments, or restricted environments.

Unverified50%

16 more timeline events

All Facts (20)

Verified

Token是大语言模型处理文本的基本单位,大约对应0.75个英文单词或1.5个汉字

90%
Verified

The GPT series uses tiktoken (based on BPE encoding) for tokenization.

80%
Verified

OpenAI provides the open-source tool tiktoken, which allows developers to estimate token counts before calling the API.

80%
Verified

OpenAI has used a variant of BPE since GPT-2, and GPT-4's cl100k_base vocabulary contains approximately 100,000 tokens.

65%
Verified

OpenAI uses the tiktoken tokenizer for token metering.

65%
Verified

The number of tokens consumed by the same Chinese text may differ by 30%–50% across different large model service providers.

65%
Unverified

LLaMA 3的分词器从SentencePiece升级为基于tiktoken的BPE分词器,词表大小扩展至128,256

90%
Unverified

OpenAI's GPT series uses the tiktoken library, with vocabulary sizes typically ranging between 50,000 and 100,000 Tokens

85%
Unverified

OpenAI uses the tiktoken tokenization algorithm, and Google uses the SentencePiece tokenization algorithm.

60%
Unverified

tiktoken is OpenAI's open-source tokenizer library, and cl100k_base is its commonly used encoding scheme; an English word typically corresponds to 1-2 tokens, while Chinese uses more.

50%
Unverified

The OpenAI API's logit_bias parameter does not accept the word itself as a key but requires token ID strings, which must be obtained by encoding with the tokenizer matching the model (such as the tiktoken library).

50%
Unverified

An LLM gateway needs to parse the model field in the request payload to make routing decisions, use tokenizers such as tiktoken to count tokens in messages for token-based rate limiting, translate OpenAI-format tools definitions into Anthropic's input_schema, and extract and accumulate the usage field from each chunk of the response stream to compute cost.

50%
Unverified

When counting with the tiktoken library and the o200k_base encoding, the smallest git_status tool (no parameters) is only 54 tokens, while the largest search_code tool (five parameters) reaches 193 tokens.

50%
Unverified

The author's measurements show that the JSON Schema definitions of 18 tools consume 2,388 tokens, averaging 133 tokens per tool, and in a 10-step Agent run they can account for 36% of input tokens and 32% of the total bill.

50%
Unverified

tiktoken's README gives an average of about 4 bytes of text per token.

50%
Unverified

OpenAI's tokenizer is open source; in JavaScript, js-tiktoken can run in any environment (including the browser), and in Python the corresponding package is tiktoken.

50%
Unverified

Placing the tiktoken import inside the constructor rather than at the top of the module enables graceful degradation: importing the module itself requires no dependency, and ImportError only appears when a feature that cannot be satisfied is requested.

50%
Unverified

tiktoken is a compiled package and downloads vocabulary files, so it is not always suitable for lightweight libraries, network-free CI environments, or restricted environments.

50%
Unverified

Never use heuristics to bill customers or enforce hard context limits; scenarios with consequences must use tiktoken.

50%
Unverified

The factory function's auto mode prefers exact tiktoken counting and silently degrades to a heuristic method.

50%

Source Articles