---
title: "What Is a Token in LLMs? Why Billing Is Per Token and How to Count"
description: "A token is the unit an LLM processes, not a word count. Learn tokenization, input vs. output tokens, and how to count them with an official tokenizer."
url: https://cdnping.org/en/blog/what-is-token-in-llm
language: en
published: 2026-11-23
category: "AI concepts"
tags: ["token","LLM","tokenization","context window","API pricing"]
source: cdnping.org
license: Free to quote and summarize with a link to the url above.
---
# What Is a Token in LLMs? Why Billing Is Per Token and How to Count

A token is the smallest unit an LLM uses to process text. The model doesn't read "characters" or "words" directly. It first splits text into chunks called tokens, then processes and generates them one at a time. APIs charge per token because compute cost scales with the number of tokens processed, not with word count or the number of requests.

Many newcomers see "X per million tokens" and freeze: how many words is that? The answer is that there is no fixed conversion. Each model splits text differently, and the same passage of Chinese text can produce noticeably different token counts across models. So this article covers the mechanics first, then gives you a method you can follow to count tokens yourself.

## How does text get split into tokens?

A model has a vocabulary: tens of thousands to hundreds of thousands of common text fragments. When you submit text, the tokenizer splits it into fragments according to that vocabulary. Each fragment maps to an ID, and the model works on those IDs.

Rough patterns:

- A common English word is often a single token; rarer words get split into several pieces.
- Chinese may come out as one token per character, or common words may be merged into a single token, depending on how the vocabulary was trained.
- Spaces, punctuation, line breaks, and code indentation all take up tokens.
- Irregular content such as numbers, URLs, and hash strings usually splits into many small pieces, so the token count runs high.

So rules of thumb like "one token is about N characters" are only rough intuition. To count accurately, you need the tokenizer for the specific model.

## What's the difference between input and output tokens?

In a single API call, tokens fall into two groups:

- Input tokens: everything you send to the model, including the system prompt, conversation history, any files you paste in, tool definitions, and the question for this turn.
- Output tokens: the reply the model generates this time.

The two are usually priced separately, and output is generally more expensive than input, with providers typically pricing each according to its own cost structure. For the reasons and how to read a price table, see [Why output tokens cost more than input: read the price table before choosing a plan](/en/blog/why-output-tokens-cost-more).

Some reasoning models also produce "thinking" tokens. Whether and how those are billed is defined in each provider's official documentation. For troubleshooting, see [How reasoning tokens are billed: why reasoning-model bills run higher than expected](/en/blog/reasoning-tokens-billing).

## Why do longer conversations cost more tokens?

An LLM API doesn't remember what was said in the previous turn. In a multi-turn conversation, the client has to resend the earlier history, so the input for turn 10 contains all of the first 9 turns. The input token count grows with every turn.

This is also what the "context window" means: the maximum number of tokens (input plus output) that a single request can hold. Go over the limit and you either get an error or the oldest content is cut off. The exact context window differs by model; check the official documentation.

It's even more noticeable with coding agent tools, which repeatedly read files, run commands, and stuff the results back into context, consuming far more tokens than ordinary chat. For how to estimate that cost, see [AI agent tasks burn a lot of tokens: how to estimate cost and pick a plan](/en/blog/estimate-ai-agent-task-cost).

## How do I count the tokens in a piece of text myself?

Three steps:

1. Decide which model you're using. A tokenizer is tied to its model, so the numbers can change if you switch models.
2. Count with the official tool from that provider. For example, OpenAI offers a web tokenizer and the open-source tiktoken library; other providers count differently. Check the official documentation for where to find each one.
3. Use your real text, not sample text. The mix of Chinese, English, and code noticeably affects the result.

A minimal example of counting locally with tiktoken:

```python
import tiktoken

# The encoding name varies by model; use the one given in the official docs
enc = tiktoken.get_encoding("cl100k_base")
text = "token 是大模型处理文本的最小单位。"
tokens = enc.encode(text)
print(len(text), "个字符 ->", len(tokens), "个 token")
```

This result is only meaningful for models that use this encoding. Models from other providers need their own counting method, and you can't apply this one directly.

## How do I convert between tokens and word count?

Don't memorize a fixed ratio. Use sampling to get your own:

1. Pick three to five pieces of text you actually send, such as a requirements description, a block of code, and a passage of Chinese prose.
2. Count the tokens in each with the official tool above, and note the character count as well.
3. Divide the token count by the character count to get a ratio for each type of text, then estimate by category from then on.

A ratio obtained this way is more reliable than the "one Chinese character is about N tokens" figures floating around online, because it comes from your text and your model.

Once you have the ratios, you can estimate monthly usage: roughly how much text you process per day, times the ratio, times the input and output unit prices. The full method is in [How to estimate your monthly token usage: a three-step logging method](/en/blog/estimate-monthly-token-usage), and what each line of the bill means is covered in [How token billing works: an itemized breakdown of one LLM API call](/en/blog/llm-token-billing-explained).

## Common misconceptions

| Claim | Reality |
| --- | --- |
| One token is one character or one word | Only commonly true. The vocabulary decides, and a token can be half a word, one character, or several characters |
| The same text has the same token count in every model | Tokenizers differ between models, so the numbers differ |
| Only my question is billed | The system prompt, conversation history, and tool definitions all count as input |
| A short reply means a cheap call | With a very long input, the input side can account for most of the cost |
| Failed requests don't consume anything | Whether you're billed depends on the cause of the failure and the platform's rules; check the official documentation |

## If you'd rather not do the math yourself, where do you start?

Cover the basics first. If you're not familiar with calling APIs, read [What is an API? A food-delivery analogy, then how to call an AI API](/en/blog/what-is-api-for-beginners). If you'd rather get hands-on, see [How to use an LLM API: from getting a key to receiving your first reply](/en/blog/llm-api-first-request-guide).

Also, token prices and metering differ between services. For example, AGI Plan uses "CU": 1 CU equals 1,000 output tokens of a baseline model, and its four monthly tiers differ only in quota. AGI Plan is a commercial partner of cdnping. It is a monthly-subscription gateway that aggregates multiple providers, accepts payment in RMB without needing an overseas credit card, and lets tools like Claude Code and Codex connect by changing just one endpoint URL. Some models are available only outside mainland China; see the [models page](https://agiplan.dev/models) for specifics. The operator also states that it is not an officially authorized channel. For setup steps, start with the [AGI Plan beginner guide](https://agiplan.dev/startup).

Before choosing any service, estimate your own token usage with the sampling method above, then check it against the pricing page, rather than going by the advertised "tokens per month" alone.

## Next steps

1. Take three pieces of text you actually use, count them with the official tokenizer, and get your own token-to-character ratio.
2. Log a week of real usage and estimate your monthly consumption.
3. To compare response speed across services, use the [cdnping online speed test](/en) to measure connection time to each provider's API. For why access latency from mainland China behaves the way it does, see [AI API latency](/en/learn/ai-api-latency-china). To see availability and price changes for each model across providers, see [Model monitoring](/en/models).
