LLM API Billing Simplification: Web Search and Fetching Merged into Token-Based Pricing

    This article explains a cloud provider's shift to token-based billing for server-side web search and page fetching in LLM API calls, replacing per-request charges. It analyzes how the change affects cost structures, especially for Agent applications, and outlines practical architecture patterns such as layered retrieval, context budgets, caching, and summarization. It also covers reliability, compliance, observability, and a migration checklist for teams adapting to token-metered web access.

    1. Overview: Web Access Becomes a Default Capability Instead of a Paid Add-On

    A cloud provider’s LLM platform introduced new API billing rules effective November 18 at 12:00. Server-side web search and page fetching triggered during model calls are no longer billed separately per request. Instead, they are fully merged into the model’s token usage and charged only based on token consumption.

    According to publicly disclosed information, the newly free retrieval capability covers multiple developer integration paths, including the platform’s native web tools, web_search-style tools compatible with mainstream messaging protocol specifications, and web_search-style tools in the responsive API system. Previously, on October 17 of the same year, the platform had launched standalone Search and Fetch APIs backed by its in-house search engine, billed per successful request at 5 CNY per 1,000 requests. Under the new rules, retrieval and fetching are integrated into the standard model call flow and treated as a baseline capability.

    For developers, this is not a simple price cut but a structural change to the cost model: the marginal cost of obtaining external information shifts from a “fixed charge per call” to a “token expense that scales linearly with context length.”

    2. Why This Change Matters Especially for Agent Applications

    LLMs are rapidly evolving into agents with autonomous retrieval and real-time interaction capabilities. A typical Agent loop is “think — retrieve — read — think again,” and a single user question often involves multiple rounds of external information retrieval.

    Under the old per-request billing model, cost grew with the number of retrievals. Under the new model, cost grows with the volume of text injected into context. The difference is significant:

    • Many retrievals that each return only a small snippet clearly favor the new model on cost.
    • Few retrievals where a single fetch pulls an entire long article may actually increase token consumption.

    Therefore, the billing change directly affects architectural trade-offs: developers need to re-evaluate three questions — “how many retrievals,” “how much per retrieval,” and “how to compress retrieved content.”

    3. Cost Structure Comparison: A Quantitative Intuition for the Shift from Per-Request to Per-Token

    Assume a Q&A Agent triggers 100,000 retrievals per day:

    • Old model: retrieval fees alone are about 100000 / 1000 × 5 = 500 CNY/day, excluding model inference costs.
    • New model: retrieval is no longer a separate line item; cost is folded into tokens. If each retrieval introduces an average of 1,500 tokens of context, that adds roughly 150 million input tokens per day, which must be calculated against the specific unit price.

    The conclusion is not that it is “definitely cheaper,” but that cost predictability and optimization options change: the token side has many mature optimization techniques (caching, summarization, trimming, batching), whereas per-request billing offers almost no room for optimization.

    4. Architecting Web-Enabled Applications for Token-Based Billing

    4.1 Layered Retrieval: Cheap Recall First, Deep Reading on Demand

    Do not have the model fetch a large number of pages at once. A recommended three-stage flow is “retrieve snippets → judge relevance → deep-read a few sources”:

    1. # Illustrative pseudocode: layered retrieval to control context injection
    2. def answer_with_web(query, top_k=8, deep_read=2, max_chars=1200):
    3. snippets = web_search(query, top_k=top_k) # fetch only titles and snippets
    4. ranked = rerank(query, snippets)[:deep_read] # deep-read only the few most relevant sources
    5. context = []
    6. for doc in ranked:
    7. text = fetch(doc.url)[:max_chars] # truncate to control tokens
    8. context.append(text)
    9. return llm(prompt_with(query, context))

    4.2 Context Budget: Set a Hard Cap on Retrieved Content

    Define a token budget per request (for example, allocate 30% of the total input budget to external material) and trim before concatenation. In engineering practice, a conservative estimate of “character count approximates token count” can be used as a pre-check to avoid requests exceeding the budget being rejected by the server and repeatedly retried.

    4.3 Caching and Reuse: Reduce Repeated Retrievals to Zero

    Web content has strong redundancy and layered time sensitivity. Two-level caching is recommended:

    • Result cache: cache retrieval results keyed by “normalized query + time window.”
    • Content cache: cache fetched page bodies keyed by URL fingerprint, with TTL to control freshness.

    For high-frequency hot topics, cache hit rates are typically substantial, making this the most direct cost-reduction measure under the new billing model.

    4.4 Summarization and Compression: Trade One Small Model Call for Many Long Contexts

    Before injecting page bodies into the main model, first use a smaller model to generate a structured summary (key points, data, dates, sources), compressing thousands of characters down to a few hundred tokens. In multi-round retrieval scenarios, this “extra call” is often significantly cheaper than repeatedly injecting long text.

    5. Reliability, Compliance, and Observability

    • Failure fallback: when fetching fails, times out, or returns empty content, fall back to a pure model answer without web access and clearly inform the user that information may be incomplete.
    • Source traceability: retain source links and fetch timestamps for auditing and error correction.
    • Content trustworthiness: external web pages are untrusted input; guard against prompt injection by isolating and labeling retrieved content so it cannot override system instructions.
    • Compliant use: respect target sites’ terms of access and robots conventions, and control concurrency and request rates.
    • Observability: in logging and monitoring/alerting systems, separately track retrieval counts, injected token volume, cache hit rates, and total cost per request to build a cost dashboard.

    6. Migration and Implementation Checklist

    1. Map the existing call chain and mark all nodes that trigger web retrieval.
    2. Establish token budgets and truncation policies, validating on canary traffic that quality does not degrade.
    3. Roll out the caching layer and monitor hit rate and freshness metrics.
    4. Introduce pre-injection summarization compression for long-document scenarios.
    5. Build cost attribution by business dimension to avoid “total cost drops but a single scenario spikes.”

    7. Conclusion

    Merging search and fetching into token-based billing essentially turns web access from a “billable value-added module” into a “default component of model calls.” Developers should shift their optimization focus from “retrieve less” to “retrieve precisely, control context, and cache aggressively.” As agent applications scale, whoever minimizes the token cost of external information can support longer task chains and higher call frequencies on the same budget. If an enterprise wants to build similar capabilities in its own environment, it can build a retrieval-augmented and cost-governance system based on Baidu AI Cloud’s LLM platform and related general cloud products (such as object storage, message queues, logging services, and monitoring/alerting).