OpenAI token counter
Paste a prompt, document or code to see its token count and what it costs as input and as output on each OpenAI model. Counting runs in your browser.
Accuracy: Exact for the text itself on GPT-5.x models: tiktoken maps every gpt-5 model name to the o200k_base encoding, and this page runs that encoding in your browser. Two limits: the API adds a few formatting tokens for message roles and boundaries, and OpenAI has not published the encoding for GPT-6 models (they are not in tiktoken's model map), so for those the o200k_base count is the closest public reference, not a confirmed exact count.
The exact OpenAI tokenizer (about 1 MB) loads when you start typing.
This text is largely Korean, Japanese or Chinese. CJK text uses several times more tokens per character than English, and the gap between tokenizers is larger than for English, so treat non-OpenAI numbers as rough.
Cost of this text on OpenAI models
| Model | Tokens | As input | As output | × 1,000 |
|---|
Standard prices, no caching or batch discount. "As output" is what the same number of tokens costs if the model generates it. Long-context rates apply automatically when the text crosses a model's threshold. Full requests with caching and agent loops: calculator.
OpenAI tokenizer facts
| Tokenizer | Public, in the open-source tiktoken library. o200k_base: gpt-5*, gpt-4.1, gpt-4.5, gpt-4o, o1, o3, o4-mini. cl100k_base: gpt-4, gpt-3.5-turbo and the text-embedding-3 models. o200k_harmony: gpt-oss. Source |
|---|---|
| GPT-6 models | Not listed in tiktoken's model-to-encoding map. OpenAI has not published which encoding GPT-6 models use. Source |
| Exact count via API | POST /v1/responses/input_tokens takes the same input as the Responses API (text, messages, images, files, tools) and returns input_tokens. The count includes formatting tokens for message roles and boundaries that a local tokenizer does not see. Source |
| Rule of thumb | About 4 characters or 0.75 words per token for English text. Source |
Checked against the linked official documentation on 2026-10-30.
Get the exact count from the official API
Python (tiktoken, local)
import tiktoken
enc = tiktoken.get_encoding("o200k_base")
print(len(enc.encode("Tell me a joke.")))
cURL (API, includes formatting tokens)
curl https://api.openai.com/v1/responses/input_tokens \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-astra",
"input": "Tell me a joke."
}'
# → {"object": "response.input_tokens", "input_tokens": ...}
Use tiktoken for fast local counts of plain text on GPT-5.x models, and the input_tokens endpoint when you need the number the API will bill for a full request, or for GPT-6 models. Official documentation
Which OpenAI models this page counts exactly
| Model | Count on this page |
|---|---|
| GPT-6 Astra | o200k_base reference |
| GPT-6.1 Sol | o200k_base reference |
| GPT-6.1 Terra | o200k_base reference |
| GPT-6 Luna | o200k_base reference |
| GPT-6 Sol | o200k_base reference |
| GPT-5.6 Sol | exact (o200k_base) |
| GPT-5.6 Terra | exact (o200k_base) |
| GPT-5.6 Luna | exact (o200k_base) |
| GPT-5.5 | exact (o200k_base) |
| GPT-5.4 | exact (o200k_base) |
| GPT-5.4 mini | exact (o200k_base) |
6 of 11 models have a published encoding. For the rest, use the input_tokens endpoint when the number matters.
What OpenAI tokens cost
Cost of a given number of billed tokens on each model at standard rates (prices verified 2026-11-17):
| Model | 1K in | 1K out | 10K in | 10K out | 100K in | 100K out | Per 1M in / out |
|---|---|---|---|---|---|---|---|
| GPT-6 Astra | $0.01 | $0.05 | $0.10 | $0.50 | $1.00 | $5.00 | $10.00 / $50.00 |
| GPT-6.1 Sol | $0.0020 | $0.01 | $0.02 | $0.10 | $0.20 | $1.00 | $2.00 / $10.00 |
| GPT-6.1 Terra | $0.0010 | $0.0050 | $0.01 | $0.05 | $0.10 | $0.50 | $1.00 / $5.00 |
| GPT-6 Luna | $0.00010 | $0.00050 | $0.0010 | $0.0050 | $0.01 | $0.05 | $0.10 / $0.50 |
| GPT-6 Sol | $0.0020 | $0.01 | $0.02 | $0.10 | $0.20 | $1.00 | $2.00 / $10.00 |
| GPT-5.6 Sol | $0.0040 | $0.02 | $0.04 | $0.20 | $0.40 | $2.00 | $4.00 / $20.00 |
| GPT-5.6 Terra | $0.0020 | $0.01 | $0.02 | $0.12 | $0.20 | $1.20 | $2.00 / $12.00 |
| GPT-5.6 Luna | $0.00020 | $0.0012 | $0.0020 | $0.01 | $0.02 | $0.12 | $0.20 / $1.20 |
| GPT-5.5 | $0.0050 | $0.03 | $0.05 | $0.30 | $0.50 | $3.00 | $5.00 / $30.00 |
| GPT-5.4 | $0.0025 | $0.01 | $0.03 | $0.15 | $0.25 | $1.50 | $2.50 / $15.00 |
| GPT-5.4 mini | $0.00075 | $0.0045 | $0.0075 | $0.04 | $0.07 | $0.45 | $0.75 / $4.50 |
Long-context pricing: GPT-6 Astra, GPT-6.1 Sol, GPT-6.1 Terra, GPT-6 Luna, GPT-6 Sol, GPT-5.6 Sol, GPT-5.6 Terra, GPT-5.6 Luna, GPT-5.5, GPT-5.4 bill the whole request at 2× input and 1.5× output once the prompt exceeds 272,000 tokens. The output columns above assume a short prompt.
Per-model details: GPT-6 Astra, GPT-6.1 Sol, GPT-6.1 Terra, GPT-6 Luna, GPT-6 Sol, GPT-5.6 Sol, GPT-5.6 Terra, GPT-5.6 Luna, GPT-5.5, GPT-5.4, GPT-5.4 mini. Compare with other providers in the pricing table.
FAQ
Is this OpenAI token count exact?
For the text itself on GPT-5.x models, yes: tiktoken maps those models to o200k_base and this page runs that encoding (gpt-tokenizer, an open-source port). The API adds a few tokens for message roles and boundaries. GPT-6 models are not in tiktoken's model map, so for GPT-6 Astra, GPT-6.1 Sol, GPT-6.1 Terra, GPT-6 Luna, GPT-6 Sol the count is the closest public reference, not a confirmed exact count.
Which tokenizer does each OpenAI model use?
Per tiktoken's model map: o200k_base for gpt-5 models, gpt-4.1, gpt-4.5, gpt-4o, o1, o3 and o4-mini; cl100k_base for gpt-4, gpt-3.5-turbo and the text-embedding-3 models; o200k_harmony for gpt-oss. GPT-6 models are not listed.
How do I get the exact token count from the OpenAI API?
POST your request to /v1/responses/input_tokens. It accepts the same input as the Responses API (text, messages, images, files, tools) and returns input_tokens, including the formatting tokens a local tokenizer cannot see.
How many tokens is a word?
OpenAI's rule of thumb for English is about 4 characters or 0.75 words per token, so 1,000 words is about 1,333 tokens. Code and non-English text use more tokens per word.
How much do 100,000 tokens cost on GPT-6.1 Sol?
$0.20 as input and $1.00 as output at standard rates ($2.00 / $10.00 per 1M tokens, verified 2026-11-17). Cached input and the batch API are cheaper; see the calculator.
Is my text sent to OpenAI?
No. The tokenizer runs in your browser and nothing you paste leaves the page.
Other token counters
- All models token counter (every provider, tokenizer methodology)
- Claude token counter
- Gemini token counter
Tokenizer: gpt-tokenizer 3.4.0 (MIT, license), served from this site.