cl100k_base is a byte-pair-encoding (BPE) tokenizer from OpenAI's open-source tiktoken library, with a vocabulary of about 100K tokens. Paste text above to see its token count, token ids and how the text is split.
In tiktoken's model name table these names resolve to cl100k_base: `gpt-3.5-turbo`, `gpt-4`, `gpt-4-32k`, `gpt-4-1106-preview`, `text-embedding-ada-002`, `text-embedding-3-small`, `text-embedding-3-large`.
Token counts for sample texts
| Text | Sample | Tokens |
|---|---|---|
| English | The quick brown fox jumps over the lazy dog. | 10 |
| Chinese | 你好,世界!今天天气很好。 | 16 |
| Code | def add(a, b): return a + b | 11 |
FAQ
What is cl100k_base?
cl100k_base is one of the encodings shipped with OpenAI's tiktoken. It turns text into integer token ids; language models read and are billed by tokens, not characters.
Which models use cl100k_base?
According to tiktoken's model name table: `gpt-3.5-turbo`, `gpt-4`, `gpt-4-32k`, `gpt-4-1106-preview`, `text-embedding-ada-002`, `text-embedding-3-small`, `text-embedding-3-large`. Choose any of them in the selector above to see the same encoding.
How do I count cl100k_base tokens in code?
With OpenAI's tiktoken, which has Python and JavaScript (WASM) builds:
# Python
import tiktoken
enc = tiktoken.get_encoding("cl100k_base")
print(len(enc.encode(text)))
// JavaScript
import { get_encoding } from "tiktoken";
const enc = get_encoding("cl100k_base");
console.log(enc.encode(text).length);
enc.free();Is my text sent to a server?
No. Tokenization runs in your browser and the text never leaves the page. For usage statistics the page only reports which tokenizer you pick and that you started typing, never the text itself.
Why can the count differ from the usage reported by an API?
Chat requests wrap your text in special tokens and per-message formatting that this page does not show. For billing and limits, use the usage field in the API response as the authoritative number.