What Exactly Is a Token? A Full Breakdown of AI Billing, Input/Output, and Caching

Tokens are the billing unit for AI text I/O—understand input/output and caching to make sense of your bill.
The article uses "coins" as a mental model to explain that tokens are the smallest unit of text AI reads and writes, each corresponding to real cost. It establishes scale: one word is about 1-2 tokens, one line of code about 10 tokens, and a million tokens is roughly 10 novels—yet a coding assistant can burn millions in a day. It then distinguishes input tokens from output tokens: output costs 4-5x more per unit because generation is more compute-intensive; but in practice input often dominates the bill because the volume sent far exceeds what's returned. Finally, caching: re-reading the same prefix earns a 5-10x discount, provided the context start stays unchanged. Master these three points and you'll understand AI bills better than most.
Why You Need to Understand Tokens
When dealing with AI, one word keeps coming up: Token. It's a small chunk of text—sometimes a whole word, sometimes half a word, sometimes just a punctuation mark. AI doesn't "read sentences" the way we do; it reads tokens, and it writes tokens too.
The most intuitive mental model is coins. Every token you read or write costs money—either real cash or credits from your plan. Either way, it's the same meter running behind the scenes.
Pick the right mental model, and understanding bills and optimizing costs becomes much easier down the line.

Tokenization is the underlying mechanism behind the concept of tokens. AI models don't directly process characters or words; instead, a tokenizer splits text into a sequence of tokens. Common tokenization algorithms include BPE (Byte Pair Encoding), WordPiece, and SentencePiece, which build vocabularies by statistically identifying frequently co-occurring character fragments in a corpus. In English, one token often corresponds to a word or a word root, whereas in languages without space delimiters like Chinese and Japanese, a single character may be split into 1–3 tokens, and even a common word may consist of multiple tokens. This is why the same content often has a higher token count in Chinese than in English, which in turn affects billing and context window usage. Different model providers use different tokenizers, and the same text can vary by more than 20% in token count across models—an easily overlooked variable when comparing costs across models.
Sense of Scale: One Word, One Line of Code, One File
Let's first establish a sense of magnitude:
- One word is roughly 1 to 2 tokens
- One line of code is roughly 10 tokens
- A 300-line file comes out to roughly 3000 tokens
Pricing is usually quoted per million tokens, and a million tokens is roughly the text volume of 10 novels. Sounds like an astronomical number. Yet a coding assistant can burn through millions of tokens in a single day. The reason lies in the input/output structure below.

Two Directions: Input Tokens and Output Tokens
Tokens flow in two directions. What you send to the AI—questions, files, chat history—is input tokens; what the AI writes back—code, explanations—is output tokens.
Output tokens cost four to five times as much as input tokens, because generating text consumes far more compute than reading it.
But don't jump to conclusions. In practice, the biggest line item on your bill is often input, because the amount of text we send far exceeds what we get back. Understanding this is key to understanding why "output is more expensive" doesn't mean "output costs more."

Caching: The Subscription Discount for Repeated Reads
The last key concept is caching. When the AI re-reads a prefix of text identical to the previous step, the provider charges a discounted rate—something like a loyal-customer subscription discount, potentially five to ten times cheaper than the standard rate.
The prerequisite for caching to work: the beginning of the context package must not change. Once the prefix is altered, the cache is invalidated. This detail becomes crucial in the cost traps discussed later—just keep it in mind for now.

The context window is another key backdrop for understanding token flow. It refers to the maximum total number of tokens a model can "see" at once in a single request, including both input and output. Common model windows range from 8K, 32K to 128K, 200K, and some models already support millions. When conversation history or attached files exceed the window limit, the system must truncate or summarize, otherwise the request fails. The caching mechanism is designed around the context window: providers cache the unchanging prefix (such as system prompts, long documents) in VRAM or high-speed storage, and directly reuse it when the next request hits the same prefix, avoiding redundant computation. Therefore, caching not only saves money but also reduces first-token latency. Understanding window limits and cache boundaries helps plan how to organize long conversations and the order in which files are fed.
One-Sentence Summary
A token is a small coin. You pay for both what you send and what you get back; and repeatedly reading the same content costs considerably less. Keep these three things in mind—input/output direction, output costs more but input weighs more, and cache prefix stability—and you'll already understand AI bills better than most people.
Related articles

Prompt Engineering for Beginners: From Writing Prompts to Engineering Thinking
Starting from the essence and four functions of prompts, this article systematically explains the six-step process, four success criteria, learning value, and practical limitations of prompt engineering to help you build a complete understanding.

Anthropic Launches Nasdaq IPO: AI Giant's Listing and Risk Disclosures
Anthropic officially launches its Nasdaq IPO under ticker ANT, with market valuation expected to potentially exceed SpaceX's record. The prospectus devotes nearly 100 pages to AI risks, while first-half revenue grew over 14x but net losses widened sharply, reigniting the AI bubble debate.

Rust cURL Clone Uses 4,832 unsafe Blocks—Is the Memory Safety Myth Broken?
A Rust cURL clone uses 4,832 unsafe keywords, challenging Rust's memory safety narrative. We analyze what unsafe really means, compare Fil-C, and examine rewrite motives.