# Token

A chunk of text, about 4 characters or three quarters of an English word. Models read and write tokens, not letters.

AI developers · Part 01: LLM basics · Card 4 of 10 · Last updated 2026-10-13

## Analogy

Bytes in a request. You pay per token, and every limit is measured in tokens, like a hosting plan that bills by bandwidth.

## Code example

`token.ts`

```typescript
const res = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Hi!" }],
});

console.log(res.usage);
// { prompt_tokens: 9, completion_tokens: 10, total_tokens: 19 }
```

## In an agent

Long chats and big tool results eat your token budget. Every loop of an agent costs tokens.

## Practice

### Flashcards

- **What is a token?** About 4 characters of text; the unit of cost and limits.

## Questions people ask

### How many tokens is a word?

In English, one token is about four characters, or roughly three quarters of a word. So 100 words is around 130 tokens. Code, numbers and other languages often use more tokens per word. The exact count comes back in the usage field of every API response, so you never have to guess.

### Why do tokens matter for cost?

Providers bill per token, for both the text you send and the text the model writes. Agents resend the whole conversation on every loop step, so long histories and big tool results get paid for again and again. Keeping prompts and tool outputs short is one of the easiest ways to cut an agent's bill.

## Related concepts

- [LLM](https://studyvisually.com/learn/tech/ai-developers/llm-basics/llm)
- [Next-token prediction](https://studyvisually.com/learn/tech/ai-developers/llm-basics/next-token-prediction)
- [Who decides the next step](https://studyvisually.com/learn/tech/ai-developers/llm-basics/ai-levels)
- [Context window](https://studyvisually.com/learn/tech/ai-developers/llm-basics/context-window)

Web page: https://studyvisually.com/learn/tech/ai-developers/llm-basics/token
Study this card in the app: https://studyvisually.com/app/learn?category=ai-developers&card=token
