# Tokens and Token Counting for OpenAI and Claude (/models/tokens)

Tokens are the unit language models read, write, and bill. Counting them tells you what a call costs and whether it fits the model’s context window.

## What a token is \[#what-a-token-is]

A token is a whole word, part of a word, a punctuation mark, or a run of whitespace. In English, one token averages about four characters, so 1,000 tokens is roughly 750 words. Code, non-English text, and numbers usually take more tokens per character.

## Exact counts and estimates \[#exact-counts-and-estimates]

OpenAI publishes its tokenizer encodings, tiktoken, so OpenAI token counts can be computed exactly: o200k_base for GPT-4o and newer models, cl100k_base for older GPT-4 and GPT-3.5 models. Anthropic, Google, and most other providers do not publish a tokenizer you can run locally; count with their token counting APIs, or estimate from character length.

## Why token counts matter \[#why-token-counts-matter]

Tokens set both the price of a call and whether it fits the model’s context window. An agent that resends its system prompt, tool definitions, and conversation history on every turn can turn a small prompt into a large bill, so counting each piece shows where to trim. See [LLM API pricing](/models/pricing) for per-token rates and the [context window comparison](/models/context-windows) for each model’s limits.

## Frequently asked questions \[#frequently-asked-questions]

### How do I count tokens for OpenAI models? \[#how-do-i-count-tokens-for-openai-models]

Use OpenAI's tiktoken library with the encoding for your model: o200k_base for GPT-4o and newer models, cl100k_base for older GPT-4 and GPT-3.5 models. It is the same tokenizer the OpenAI API uses to bill input.

### Can I count tokens for Claude? \[#can-i-count-tokens-for-claude]

Anthropic does not publish a tokenizer that runs locally. For an exact Claude count, call the Anthropic token counting API with the same messages you plan to send; otherwise estimate from character length.

### How many tokens is 1,000 words? \[#how-many-tokens-is-1000-words]

About 1,300 tokens for typical English prose with OpenAI tokenizers, since one token averages about four characters. The ratio varies with vocabulary, formatting, and language.

### How do token counts translate to cost? \[#how-do-token-counts-translate-to-cost]

Each model bills input and output tokens at its own rate per one million tokens, and some switch to a higher long-context rate once a request crosses a threshold. Multiply each count by its rate and add them; the pricing page lists every current model’s rates.
