# Token

> The Token is the basic unit of text that a language model processes.

## What is a token in an LLM?

The piece of text, such as a word, part of a word or a symbol, that an LLM reads and generates. Model limits and API pricing are usually measured in tokens.

- Topic: Language Models
- Type: concept

## Example

Wrong:

```js
const words = text.split(' ').length;
if (words > 4000) throw new Error('Input too long');
```

Right:

```js
const tokens = await countTokens(text); // tokenizer of the model in use
if (tokens > MAX_INPUT_TOKENS) throw new Error('Input too long');
```

The limit is checked in tokens with the model's own tokenizer, since word counts underestimate tokens, especially outside English.

## Common mistakes

- Assuming one word equals one token, so text in some languages costs far more than expected.

## Key points

- Limits and costs are estimated in tokens, not in characters or words.
- Code that splits or trims text by tokens uses the tokenizer of the model in use.

## Interview questions

### How many words are in a token?

In English a token is often about three quarters of a word on average, but it varies by tokenizer, language and content like code.

### Why do some languages use more tokens?

Tokenizers are often trained mostly on English text, so words in other languages and scripts get split into more, smaller pieces.

### Are input and output tokens priced the same?

Often not. Many APIs charge more for output tokens than input tokens, and cached input may cost less.

## Related cards

- [Tokenizer](https://wonderium.dev/ai/tokenizer.md)
- [Context Window](https://wonderium.dev/ai/context-window.md)
- [Token Cost](https://wonderium.dev/ai/token-cost.md)
- [Max Tokens](https://wonderium.dev/ai/max-tokens.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/token
- Last updated: 2026-11-25
