LLM API Billing Simplification: Search and Web Fetching Folded into the Token Model

    This article explains a shift in LLM API billing where server-side web search and page fetching are no longer sold as a separate add-on per thousand requests, but are merged into token usage. It covers why this is a change in billing dimension rather than a simple price cut, how to estimate per-session cost under token-based billing, a context-budget strategy for building prompts, six key design points for retrieval-augmented pipelines, observability and cost governance practices, and common mistakes to avoid. Readers will find practical guidance on controlling context growth, caching, retrieval snippet handling, and cost monitoring. Specific prices and rules should be confirmed with the official announcement.

    1. What Changed: From Per-Call Billing to Per-Token Billing

    A cloud provider’s LLM platform recently adjusted its API billing policy: the server-side web search and page fetching triggered when developers call a model are no longer charged as a standalone value-added item. Instead, they are merged into model token usage and settled under a single metric. Previously, these capabilities were typically sold at a fixed unit price per thousand requests, as an add-on cost layered on top of model invocation fees.

    This is not a simple price reduction, but a migration of the billing dimension: from the “number of external information retrievals” to the “token consumption of model inference.” For developers, cost predictability improves, and the bill structure converges from a multi-layer stack of “model fee + tool fee + retrieval fee” into a single metric.

    Note that specific prices and rules should be based on the official announcement. This article only discusses the architectural and design implications of this billing model change.

    2. Why This Is a Change at the Cost-Structure Level

    In agent-style applications, a single user question is often not a single model call but a chain: intent recognition, query rewriting, retrieval, page fetching, content cleaning, re-reasoning, and sometimes a second round of retrieval. Under the old billing model, every retrieval and fetch along the chain was priced independently, so cost was linearly related to the number of retrievals—and the number of retrievals is decided by the model’s autonomous choices. One extra round of hesitation from the model meant one more slice on the bill.

    Under the new model, retrieval and fetching are absorbed into the token system, and cost is driven mainly by input and output context length. This has three direct consequences:

    • Cost predictability: you can estimate the cost of a single session from context length, which makes budgeting and rate limiting easier.
    • Misaligned incentives removed: there is no need to artificially suppress retrieval rounds to save money; the model can decide retrieval depth autonomously based on task needs.
    • Shift in optimization focus: the goal moves from “reducing the number of calls” to “controlling context size,” and engineering effort shifts toward trimming retrieval results and caching.

    3. How to Model Cost Under Token Billing

    A practical way to estimate cost is to break a single session into three parts:

    1. Cost per session ≈ (system prompt + tool definitions + conversation history + retrieved snippets) × input unit price
    2. + model output length × output unit price
    3. + duplicate billing factor from retrieved snippets

    The “duplicate billing factor” is the most easily overlooked: in multi-turn conversations, if an entire page body is repeatedly placed into the context, the same content is billed again on every turn. So controlling context growth matters more than controlling the number of retrievals.

    In engineering practice, set a context budget for each session, for example:

    1. CONTEXT_BUDGET = 24000 # unit: tokens
    2. def build_context(system, history, snippets):
    3. fixed = count_tokens(system) + count_tokens(history)
    4. remain = CONTEXT_BUDGET - fixed
    5. picked, used = [], 0
    6. for s in sorted(snippets, key=lambda x: x["score"], reverse=True):
    7. cost = count_tokens(s["text"])
    8. if used + cost > remain:
    9. continue
    10. picked.append(s)
    11. used += cost
    12. return picked, used

    This strategy of “deduct fixed overhead first, then greedily fill by relevance” maximizes information density within a limited budget.

    4. Six Key Design Points for the Retrieval-Augmented Pipeline

    1. Layered caching. Cache retrieval results keyed by normalized query text, and cache fetched page bodies keyed by content fingerprint, with differentiated TTLs: short caching for time-sensitive queries and long caching for static knowledge. A cache hit can skip the external request entirely, significantly reducing latency and context bloat.

    2. Query rewriting and deduplication. Rewrite colloquial user questions into several high-quality search queries, and merge near-duplicate results to avoid the same source repeatedly occupying the context.

    3. Fetch timeout and fallback. Set a hard timeout and a maximum body length for fetching; on timeout, return a summary or skip that source so the chain is not stalled by a single point.

    4. Retry and idempotency on failure. Retrieval and fetching must be re-entrant; retries should use exponential backoff with an upper limit, and write operations and side effects must be isolated from read operations.

    5. Snippet structuring. Normalize retrieval results into fields such as title, source, time, body summary, and confidence, making it easier for the model to cite them and for the frontend to show provenance.

    6. Citation and compliance. Retain sources and timestamps, filter copyright- and privacy-sensitive content, and provide verifiable citations at the output layer.

    A generic tool interface definition can stay as follows:

    1. {
    2. "tool": "web_search",
    3. "input": {"query": "...", "top_k": 5, "time_range": "recent"},
    4. "output": [{"title": "...", "url": "...", "snippet": "...", "published_at": "..."}]
    5. }

    5. Observability and Cost Governance

    After the billing metric is simplified, a self-built observability system becomes more important: record per session the number of retrievals, fetch success rate, average snippet length, cache hit rate, and input/output token distribution, and set alert thresholds for tokens per session. If you use general cloud capabilities, you can rely on log services, monitoring and alerting, and message queues to handle collection, aggregation, and asynchronous peak shaving, moving long-running fetches off the main chain.

    6. Common Mistakes

    • Assuming “free” means unlimited retrieval: tokens are still a hard constraint, and the longer the context, the lower the marginal return.
    • Stuffing an entire page into the context: noise dilutes key information and amplifies duplicate billing.
    • Missing caching: repeatedly retrieving for the same question is the most typical waste.
    • Ignoring freshness: without recording fetch time, the model may cite outdated conclusions.

    7. Conclusion

    Folding web retrieval and fetching into the token system essentially makes external information access a baseline feature of model calls, keeps complexity on the platform side, and returns certainty to developers. The response for developers is equally clear: rebuild the pipeline around a context budget, and use caching, trimming, fallback, and observability to keep costs contained. If you are running such a pipeline on Baidu AI Cloud’s general cloud products, it is also advisable to prioritize layered caching and token-budget alerts first, as these two usually improve the bill fastest.