LLM API Billing Optimization: How Search and Web Fetching Are Now Metered as Tokens

    This article explains a billing model change in which server-side web search and page fetching triggered during LLM API calls are no longer billed as separate items but are counted toward model token usage. It breaks down what the change means, how it shifts cost drivers and risks, and the specific impact on AI agent and RAG pipelines. Readers will find practical engineering techniques for controlling costs under merged billing, including context budgeting, content cleaning, layered summarization, caching, observability, and budget guardrails, along with migration and governance recommendations.

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

    A large model service platform recently revised its billing model. Starting at 12:00 Beijing time on November 18, 2026, web search and page fetching triggered by the server during model calls are no longer billed as an independent item. Instead, they are counted only toward the model’s token usage. In other words, what used to be settled separately as “search/fetch request counts” is now merged into the token bill for model inference.

    There are three typical entry points that trigger server-side internet access:

    1. The model’s built-in web tools.
    2. The search tool in an Anthropic-compatible interface system.
    3. The search tool in Responses-style interfaces.

    To avoid brand-specific references, this article uses “web tools” and “search tools in compatible interfaces” as generic terms.

    As background, the platform launched standalone search and fetch interfaces on October 17 of the same year. The search interface returns structured web results for a query, and the fetch interface returns the title and body of a single web page in Markdown format. Both use a proprietary search engine to provide real-time web content for agent and RAG applications. They were previously billed at 5 CNY per 1,000 successful requests. This adjustment effectively packages that capability into token-based billing.

    2. The Essence of the Change: Cost Consolidation and Risk Shift

    Switching from per-call to per-token billing is not simply a price increase or decrease; it is a migration of the cost structure.

    1) Unified billing dimension. Developers no longer need to model “search counts” and “inference tokens” separately. The bill converges to input tokens, output tokens (and cache hits, if any). This reduces the complexity of financial reconciliation and budget modeling.

    2) Changed cost driver. Under per-call billing, cost was driven mainly by request frequency. Under token-based billing, cost is driven by the volume of text injected into the context. The longer the search results and page content, the more input tokens are consumed, and the higher the cost.

    3) Shifted risk point. Previously, you could control costs by reducing the number of calls. Now you must control the content volume injected per call. Long pages, redundant summaries, and repeated snippets all amplify token consumption.

    4) Clearer benefit scenarios. For high-frequency retrieval-augmented scenarios with small result sets and short summaries, merged billing is usually more favorable. For low-frequency scenarios that fetch very long documents, the model needs to be re-evaluated.

    3. Impact on Agent and RAG Applications

    Agent scenarios typically follow a “plan-retrieve-execute-summarize” loop. Web search results enter the next inference round as tool return content. After the billing merge, every round in a multi-turn loop counts tool results as input tokens, so the token amplification effect is more pronounced in long-chain agents.

    In RAG scenarios that use a conventional “retrieve, rerank, then concatenate” pipeline, web page content converted to Markdown often contains a large amount of noise text such as navigation, copyright notices, and ads. Without cleaning and truncation, input tokens will expand significantly.

    The following pseudocode illustrates this amplification:

    1. for step in agent_loop:
    2. query = plan()
    3. results = web_search(query) # Triggers server-side search
    4. docs = fetch(urls) # Triggers server-side fetch
    5. context = clean_and_truncate(docs, max_tokens=2000)
    6. answer = model(context) # Input tokens include context

    The max_tokens setting directly determines the cost ceiling.

    4. Engineering Practices: Optimizing Costs Under Merged Billing

    1) Context budgeting. Set an input token budget for each model call. Extract structured content from search results (titles, key points, key passages) before concatenating them.

    2) Fetch content cleaning. Remove template elements from Markdown content, strip headers, footers, and repeated paragraphs, and prioritize the main body.

    3) Layered summarization. Use a small model or rules for coarse filtering first, then let the main model produce the final answer, reducing the input volume for the main model.

    4) Caching and reuse. Build result caches for high-frequency queries to avoid repeatedly triggering search and fetch; use fingerprint deduplication for identical documents.

    5) Observability. Use logging services and monitoring/alerting systems to record token consumption per round, search trigger counts, and pipeline latency, forming a cost dashboard. General cloud product categories offered by Baidu AI Cloud (such as object storage, message queues, container platforms, logging services, and monitoring/alerting) can be used to support caching, asynchronous fetching, and observability.

    6) Budget guardrails. Set per-request token limits and daily call limits at the application layer. When limits are exceeded, degrade to “answer using only the local knowledge base.”

    5. Migration and Governance Recommendations

    For existing systems, start with “billing model mapping”: convert the original per-call cost into equivalent token cost and identify high-consumption pipelines. Then perform a canary switch and compare bill differences. Finally, solidify three foundational capabilities: cleaning, truncation, and caching. Teams should incorporate “token budgets” into interface contracts, specifying the maximum input length per call to prevent individual long documents from dragging down overall costs.

    6. Conclusion

    This adjustment merges web retrieval and page fetching into token-based billing, simplifying the bill structure while pushing the focus of cost control toward “context governance.” Developers should build engineering guardrails around cleaning, truncation, caching, and observability to balance effectiveness and cost in agent and RAG applications.