New to Rust? Grab our free Rust for Beginners eBook Get it free →
What Are Tokens in ChatGPT? A Simple Explanation

ChatGPT does not read text as a stream of whole words. It turns your prompt and its reply into tokens, which are recurring pieces of characters such as a word, part of a word, punctuation, or a space-plus-word combination.
What tokens mean in ChatGPT
A token is the unit of text an OpenAI model processes. OpenAI’s documentation uses the word tokenization as an example, where token and ization can be separate tokens while a common word such as the can be one token.
A token differs from a word or character because the tokenizer and language determine the split, so use the tokenizer for the model you plan to use when an exact count matters.
How ChatGPT handles a message
When ChatGPT receives text, its model converts that text into tokens and uses those tokens as the input for generating a response. The response is generated as tokens, then converted into text for the chat window.
This explains why spelling, punctuation, and language can affect a count. It also explains why the same idea can use a different number of tokens when you rewrite it.
Input, output, and context tokens
Input tokens are the tokens you send, including instructions and any text included with the request. Output tokens are the tokens the model generates in response.
A context window is the maximum number of tokens a model can consider in one request. OpenAI documents that the limit includes input and output tokens, and some models also use reasoning tokens, so a long prompt leaves less room for a long answer.
Why tokens matter
Tokens set the amount of text that fits into a request and determine how API usage is measured.
ChatGPT plans and API billing are separate products. If you use the API, check the pricing page for the selected model instead of applying a chat subscription limit to an API request.
Count tokens with Python
The tiktoken package can count tokens with the encoding associated with a model. I ran the following script with Python 3.13.5 and tiktoken 0.13.0, and it returned seven tokens for the sample sentence.
import tiktoken
text = "Tokenization splits text into pieces."
encoding = tiktoken.encoding_for_model("gpt-4o-mini")
tokens = encoding.encode(text)
print(f"Text: {text}")
print(f"Token IDs: {tokens}")
print(f"Token count: {len(tokens)}")
The numeric token IDs are useful for inspection, but the count is the value you normally need. Use the same model name in your script and API request so the tokenizer choice stays aligned.
Expected output
The sample prints the original sentence, its token IDs, and the count produced by that model’s encoding.
Text: Tokenization splits text into pieces.
Token IDs: [4421, 2860, 76848, 2201, 1511, 12762, 13]
Token count: 7

Avoid token-count mistakes
Do not estimate a production request by counting words. A rough characters-to-tokens rule can help you sketch a budget, but it cannot replace the tokenizer when the request must fit a context window or a cost limit.
Do not quote a single token limit for ChatGPT. Model availability and limits change, and OpenAI publishes the model-specific limits in its documentation.
References
OpenAI Help Center: What are tokens and how to count them?
OpenAI API: Conversation state




