Token Cost Accounting for LLM Web-Connected Q&A

    This article explains how to calculate and control token costs for web-connected LLM question answering after retrieval tool fees drop to zero. It breaks down the billing model into three token categories (uncached input, cached input, output) and peak versus off-peak rates, walks through a baseline estimate for 1,000 requests, shows how costs scale linearly with usage, and lists practical optimization techniques such as prefix reuse, context trimming, output constraints, and off-peak scheduling. Readers will get a reproducible budgeting framework and a usage-logging code example.

    1. Background: With Tool Fees Gone, Costs Shift to Tokens

    When people discuss the cost of web-connected question answering, attention usually goes to retrieval tool invocation fees. Once a cloud service sets the built-in web retrieval tool fee to 0, the bill structure changes materially: the one-time, per-call charge disappears, and nearly everything left is token consumption on the model side. Cost shifts from a countable number of calls to an accumulative text length, so the budgeting model has to be rebuilt.

    It is worth stressing that a zero tool fee does not make the whole request free. A complete web-connected Q&A flow typically includes: the user’s question, query rewriting for retrieval, external content recall, assembly of recalled content into the context, model inference, optional multi-step reasoning, and final answer generation. Apart from the retrieval tool itself being free, the model’s processing of this text is still metered as input and output tokens. Treating “no tool fee” as “free to use” is the most common starting point for budget overruns.

    2. Pricing Model: Three Token Types and Two Time Tiers

    Mainstream LLM services use highly consistent billing dimensions, which can be abstracted as three token types plus a time-tier coefficient:

    • Uncached input: the part of the current request that the server cannot reuse from a historical prefix; this has the highest unit price.
    • Cached input: the part reused by sharing a prefix with historical requests; the unit price is usually only a few percent of uncached input.
    • Output: includes the final answer, plus reasoning content produced by models that support a thinking mode.

    On the time dimension, a common industry practice is to treat weekday daytime as peak and all other time (including nights, weekends, and public holidays) as off-peak, with the peak unit price roughly double the off-peak price. Using a general pricing range from a cloud vendor as an illustration (unit: CNY per million tokens):

    Billing item Off-peak Peak
    Uncached input 1 2
    Cached input 0.02 0.04
    Output 4 8

    Peak hours generally refer to Beijing time on weekdays from 9:00 to 12:00 and 14:00 to 18:00. The exact unit prices and time-tier divisions should follow the provider’s current published rates; the numbers here only demonstrate the calculation framework.

    3. Baseline Estimate for 1,000 Q&A Requests

    Assume each task accumulates 6,000 uncached input tokens and 1,000 billable output tokens (including thinking usage), with no retries or cache hits. That means 1,000 tasks correspond to 6 million input and 1 million output tokens:

    • Off-peak: 6 × 1 + 1 × 4 = 10 CNY
    • Peak: 6 × 2 + 1 × 8 = 20 CNY

    Per request, that is roughly 0.01 or 0.02 CNY. Two points here are very easy to misread:

    First, the 6,000 input tokens are the entire billable input for the whole task, not the user’s opening question. In web-connected scenarios, recalled page body text, titles, and summaries are stitched into the context, and this often makes up the vast majority of the input. Estimating only by the length of the question usually underestimates by one or two orders of magnitude.

    Second, whether the model actually went through the web-connected path should be judged by call records and characteristics of the returned content, not by subjective assumption. If it did not connect to the web, there is no recalled text in the input, and the cost will be significantly lower than the baseline above.

    4. Scaling Usage: Linear Extrapolation and Scale Effects

    A single-point estimate is not enough to support capacity planning; with the same unit prices, you can scale linearly:

    Input per task Output per task Off-peak (1,000 requests) Peak (1,000 requests)
    6000 1000 10 CNY 20 CNY
    12000 2000 20 CNY 40 CNY
    20000 3000 32 CNY 64 CNY

    Linear extrapolation holds as long as unit prices and the time-tier structure stay unchanged. As scale grows, a higher cache hit rate will make the actual bill lower than the purely linear result; conversely, if contexts differ greatly between tasks and prefixes cannot be reused, the cost will be closer to or even exceed the linear value.

    5. Actionable Cost Optimization Techniques

    1. Prefix reuse. Put the system prompt, tool descriptions, and fixed templates at the very front of the context and keep them byte-for-byte stable, so this part falls into the cached-input tier and the unit price can drop by one or two orders of magnitude.
    2. Context trimming. Denoise, deduplicate, and cap the length of recalled content, keeping only fragments relevant to the question, which directly compresses the largest input block.
    3. Output constraints. Thinking mode can significantly amplify output tokens; for latency- and cost-sensitive scenarios, explicitly limit reasoning depth and answer length.
    4. Time-tier scheduling. Schedule batch offline tasks (log analysis, document summarization, offline labeling) into off-peak hours where possible, cutting cost roughly in half.
    5. Observability. Use a logging service and monitoring alerts to record the three token categories (input, cache hits, output) for each request, aggregate them by business dimension, and form a regression-capable budget baseline.

    Illustrative usage collection logic:

    1. def record(task_id, usage):
    2. # usage: prompt_tokens / cached_tokens / completion_tokens
    3. billable_input = usage["prompt_tokens"] - usage["cached_tokens"]
    4. cost = (
    5. billable_input * PRICE_INPUT
    6. + usage["cached_tokens"] * PRICE_CACHED
    7. + usage["completion_tokens"] * PRICE_OUTPUT
    8. ) / 1_000_000
    9. metrics.increment("llm_cost_yuan", tags={"task": task_id}, value=cost)

    6. Conclusion

    After tool fees drop to zero, the cost of web-connected Q&A is determined entirely by token structure: input length is the main driver, output and time tier are coefficients, and cache hits are the biggest optimization opportunity. Using a three-part model of “tokens per task × number of requests × unit price” for budgeting, combined with prefix reuse, context trimming, and off-peak scheduling, the cost of Q&A at the 1,000-request scale can be kept stably in a very low range and remains predictable as it scales. All numbers are budgeting assumptions; the actual bill should follow the provider’s published prices and real call records.