AI tokens, context and cost: plan the request before the bill
Before sending a long document to a model, answer two different questions: will it fit, and what might it cost? Word count alone settles neither, because the unit of processing and often pricing is the token.
A token is not a fixed word
A tokenizer splits text according to vocabulary and rules associated with a model. A word may remain one unit or become several pieces. No fixed words-to-tokens conversion works across all languages and models.
An exact count for one tokenizer describes that tokenizer only. A different model, message formatting, instructions or tool definitions can change the complete request count.
References: Hugging Face — Tokenization Algorithms
Reserve space for the answer
For a context budget combining input and output, include instructions, history and attached content, then reserve the answer and a margin. Check separate input and output limits where applicable; limits belong to the chosen model and mode.
An illustrative 16,000-token budget with 10,000 input tokens and 2,000 reserved output tokens leaves 4,000 as margin. A 16,000-token document alone leaves no space for the rest of that request.
References: Google AI for Developers — Understand and Count Tokens
Calculate what is actually billed
Use stated input and output rates with their unit, such as one million tokens. Record the model and price date. This estimates API usage, not a monthly chat subscription.
Caching, reasoning, media or tools can have separate usage categories. Inspect the actual usage statement rather than treating every sent or displayed token as one billing class.
References: Google AI for Developers — Understand and Count Tokens
Reduce waste before reducing useful context
Remove accidental repetition and select relevant excerpts instead of attaching a complete archive every time. Do not discard facts that change the answer merely to lower a counter. For document retrieval, chunk and vector counts estimate resources; they do not guarantee retrieval quality.
Cost example using invented rates, not a provider quote
Assume 8000 input tokens at $2 per million and 1000 output tokens at $6 per million. Cost = 8000 ÷ 1,000,000 × 2 + 1000 ÷ 1,000,000 × 6 = $0.022 per request.
One hundred identical requests would cost $2.20 under those assumptions, excluding other charges and retries. Replace both counts and rates with your actual measurements before spending.