{"head":{"title":"What Is a Token in an LLM? Definition | OceanLab","description":"A token is the unit an AI language model reads and writes, and the unit most LLM APIs bill by. How tokens work, why counts differ, and common mistakes.","canonical":"https://oceanlab.in/glossary/token"},"crumbs":[{"name":"Home","path":"/"},{"name":"Glossary","path":"/glossary"},{"name":"token","path":"/glossary/token"}],"slug":"token","term":"Token (LLM)","aka":[],"category":"LLM costs","short":"The unit an AI language model reads and writes, and the unit most LLM APIs bill by.","body":[["A ",{"href":"/glossary/llm","text":"language model"}," does not read words or letters. A tokenizer first splits text into tokens, which are often parts of words, whole short words, punctuation or spaces. Images and audio are also turned into tokens when a model accepts them."],["Each model family has its own tokenizer, so the same text can be a different number of tokens on different models. APIs usually price input tokens and output tokens separately, per million tokens, and output is often the dearer of the two."]],"why":["Tokens are the meter on every LLM bill and the unit of the ",{"href":"/glossary/context-window","text":"context window"},". Knowing roughly how many tokens a feature uses per call, split into input, cached input and output, is the starting point for any cost estimate."],"example":["A support assistant sends a long system prompt, the customer's last few messages and a help article with every call, then writes a short reply. Almost all of its tokens are input, and most of that input is the same on every call, which makes it a good case for ",{"href":"/glossary/prompt-caching","text":"prompt caching"},"."],"inBuild":null,"mistakes":[["Estimating cost from word counts. Count tokens with the model's own tokenizer."],["Ignoring the token mix. Two features with the same total can cost very different amounts if one is output-heavy."],["Forgetting hidden tokens: system prompts, tool definitions, retrieved documents and reasoning output all count."]],"related":[{"href":"/glossary/context-window","label":"Context window","detail":"The most tokens a model can take in and produce in one request."},{"href":"/glossary/prompt-caching","label":"Prompt caching","detail":"Reusing the processed start of a prompt across calls, so repeated input is billed at a lower rate."},{"href":"/glossary/batch-api","label":"Batch API","detail":"A way to send many LLM requests to run later, usually at a discount."},{"href":"/glossary/inference","label":"Inference (AI)","detail":"Running a trained AI model on new input to get an output, such as an answer, a label or an embedding."}],"tools":[{"href":"/tools/token-counter","label":"Token counter","detail":"Free tool"},{"href":"/tools/llm-api-cost-calculator","label":"LLM API cost calculator","detail":"Free tool"}],"links":[{"href":"/pricing/categories/llm-api","label":"LLM API pricing","detail":"Model prices side by side, with sources."},{"href":"/pricing","label":"Pricing library","detail":"Software and API prices, each with its source and date."}],"sources":[],"legal":false,"updatedAt":"2026-10-25"}