Why LLM Token Usage Accumulates Across Conversation Turns
This article explains why LLM API token consumption grows with each conversation turn. It covers how stateless chat APIs require clients to resend message history, a token budget calculation showing that input tokens dominate long-conversation costs and grow linearly, why claims about Chinese token efficiency should be verified with real corpus sampling, and five engineering techniques for controlling cost: context trimming, summarization, retrieval-based injection, prompt slimming, and observability with budget guardrails.
1. First, correct a common intuition: the last message you see is not the entire request
Many developers investigating LLM API costs focus on the last line typed into the chat window and wonder, “I only asked one question, so why is the usage so high?” The root cause is that mainstream LLM chat APIs are designed to be stateless. The server does not remember what was said in previous turns. To maintain a continuous conversation, the client must reassemble the message history into the current request using the agreed structure.
A typical request body contains three kinds of content:
{"messages": [{"role": "system", "content": "Fixed instructions: role setup, output format, business rules"},{"role": "user", "content": "Turn 1 question"},{"role": "assistant", "content": "Turn 1 answer"},{"role": "user", "content": "Turn 2 question"}]}
In other words, the second request carries the fixed instructions, the first question-and-answer pair, and the second question all at once. The answer the model generated in the previous turn becomes new input in the next turn and is billed again (cached portions are settled according to cache rules). Two points are worth stressing. First, context strategies vary widely across application shells: some retain the full history, while others trim, summarize, or retrieve on demand. Second, billing is always based on the content actually submitted in the current request and the usage fields returned by the API, not the visual length of the chat box. When investigating costs, the first step should be to open the request logs and usage records, not to count the characters in the last message.
2. A quantitative walkthrough: how input volume grows over 20 consecutive turns
To isolate the effect of history accumulation, assume a simplified set of budget parameters: fixed instructions of 1000 tokens, 100 tokens for each new question, 500 tokens for each answer, and every turn carrying the complete prior history. Use non-thinking mode, no tool calls, no retries, and set aside for now the differences introduced by message wrapping.
Each completed turn adds 100 + 500 = 600 tokens to the history, so the input for turn n is:
Input(n) = 1000 + 100 + 600 × (n - 1)
Plugging in the values: turn 1 is 1100, turn 5 is 3500, turn 10 is 6500, and turn 20 is 12500. The cumulative input across 20 turns is about 131000 tokens, while the cumulative output is only 10000 tokens. The conclusion is clear: the input side is the main cost source for long conversations, and it grows linearly. Also note that tokens do not map one-to-one to Chinese characters: 100 tokens does not equal 100 Chinese characters, and Chinese, English, code, punctuation, and whitespace all tokenize with different efficiency. Budgets must be based on actual usage.
3. Chinese information density: a claim that needs rigorous framing
“The same meaning takes fewer tokens in Chinese” may hold for specific corpora, but it cannot be treated as a universal law. The reason is that tokens are the output of a tokenizer, and vocabulary coverage, corpus mix, capitalization and spacing, technical terms, and code symbols all affect how finely text is split. The rigorous approach is to sample and measure with your real business corpus, count the effective information per thousand tokens, and estimate the budget from that, rather than relying on broad language-level conclusions.
4. Five categories of engineering techniques to bring costs down
- Context trimming: set a sliding window that keeps only the most recent k turns, or dynamically evict the oldest messages against a token budget.
- Summarization: generate a structured summary of early conversation (conclusions, constraints, to-dos) and replace thousands of tokens of original text with a few hundred.
- Retrieval on demand: place long documents in object storage or a vector retrieval pipeline and fetch relevant fragments per question, instead of stuffing in the whole document.
- Prompt slimming: keep only the necessary rules in the fixed instructions and move lengthy examples to retrievable resources; keeping the same prefix stable helps prefix cache hits.
- Observability and budget guardrails: log input, output, and cached tokens per request at the gateway layer, set per-session and per-user quotas, and use logging services with monitoring alerts to locate abnormal spikes.
5. Implementation suggestions
Start by building a local estimator with the formula Input(n) = fixed instructions + first-turn question + (n-1) × (per-turn Q&A), then calibrate the parameters against real usage. Enable summarization and window trimming by default for long sessions, and default to retrieval injection for document-heavy scenarios. If you use the relevant model services from Baidu AI Cloud, you can collect usage and manage quotas uniformly on the gateway side, turning a “feels expensive” impression into a cost curve that is explainable, predictable, and optimizable.
