LLM API Billing Optimization: Search and Web Fetching Folded into Token Metering

    This article explains a billing model change in which server-side web search and page fetching triggered by a large model API are no longer charged separately and are instead settled entirely through token usage. It covers why the change was made, how the cost structure shifts, a sample cost comparison, and the practical impact on AI Agent and RAG applications. Readers will learn how to rewrite budget models, manage context length, apply caching, and build cost observability around input and output tokens.

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

    A cloud provider announced a billing rule update on its official website: starting at 12:00 Beijing time on November 18, 2026, when developers call a model, the web search and page fetching triggered by the server side will no longer be billed separately. The entire charge will be settled based on the model’s token usage only.

    A key distinction is needed here. This applies to retrieval and fetching triggered on the server side, not to crawlers or self-built retrieval pipelines implemented by developers. The triggering scenarios typically fall into three categories: the built-in web tools of the model service, web_search-style tools exposed through an Anthropic-style interface, and web_search-style tools in a Responses-style interface. In other words, as long as a request enters the tool-calling orchestration flow of the model service and the platform performs the search and page fetching, those actions no longer generate a separate per-call charge.

    Previously, the platform offered standalone retrieval and fetching interfaces billed by the number of successful requests, at a rate of 5 yuan per 1,000 successful requests. The retrieval interface returned structured web results for a query, while the fetching interface returned the title and body of a single page in Markdown format. Both interfaces provided real-time web content for Agent and RAG applications. This adjustment effectively merges that separately billed path into the token-based billing system.

    2. Why the Change: Three Technical Reasons

    First, tool calls and model inference are tightly coupled at runtime. In a single “think-search-think again” loop of an Agent, the retrieval results are fed back into the model as context. Retrieval is one step in the inference chain, not a separately sold value-added capability. Splitting the two into separate metering units makes cost attribution difficult.

    Second, per-call billing is unfriendly to developers. Retrieval requests vary enormously in size: a broad query may return only a few items, while a complex query may trigger multiple rounds of rewriting and repeated fetching. Charging per call cannot reflect actual resource consumption and easily leads to unpredictable budgets.

    Third, tokens are a general measure that is closer to resource consumption. Whether it is the prompt, the context injected from retrieval results, or the model output, everything is ultimately converted into tokens. Unifying everything under the token measure simplifies the bill structure and makes capacity planning easier.

    3. How the Cost Structure Changes: A Comparison

    Assume an Agent application makes 10,000 model calls per day on average, 30% of which trigger server-side retrieval, and each retrieval injects about 1,200 tokens of web page content.

    Before the change: the retrieval cost is about 10000 × 30% ÷ 1000 × 5 = 15 yuan per day, plus the model token cost.

    After the change: retrieval is no longer billed separately, but the injected 1,200 tokens count as input tokens and are settled at the model’s input price.

    The conclusion is not simply that it is “definitely cheaper.” The key is the ratio between your input token price and the retrieval call frequency. If retrieval is frequent but each injection is short, the new model is usually more economical. If retrieval is sparse but a single injection is extremely long, you need to recalculate. Developers should run the numbers based on their actual call distribution rather than applying a generic conclusion.

    4. Concrete Impact on Agent and RAG Applications

    1. The budget model needs to be rewritten. The original two-part formula of “retrieval calls × unit price + token cost” is simplified into a single token formula, improving explainability on the finance side.
    2. Context management becomes more important. Since retrieved content enters the bill as tokens, trimming irrelevant passages, compressing duplicate content, and limiting the number of returned items directly translate into savings.
    3. Caching strategies gain value. Caching results for high-frequency repeated queries both reduces latency and cuts injected tokens.
    4. Observability metrics need to be filled in. It is recommended to log the input tokens, output tokens, whether a tool call was triggered, and the tool return length for each request, forming an attributable cost dashboard.

    An illustrative instrumentation structure can be designed like this:

    1. record = {
    2. "request_id": req_id,
    3. "input_tokens": usage.input_tokens,
    4. "output_tokens": usage.output_tokens,
    5. "tool_triggered": bool(tool_calls),
    6. "tool_result_chars": sum(len(r) for r in tool_results),
    7. "estimated_cost": usage.input_tokens * price_in + usage.output_tokens * price_out,
    8. }

    5. Implementation Recommendations

    First, streamline prompts and context. Truncate retrieval results by relevance and keep only the top few items; summarize long pages before injecting them.

    Second, establish a tiered retrieval strategy. Do not trigger web access for simple questions; open tools only for complex questions to reduce ineffective token injection.

    Third, improve monitoring and alerting. Using log services and monitoring and alerting capabilities, set threshold alerts on token consumption to prevent abnormal calls from inflating the bill.

    Fourth, keep the architecture portable. Abstract tool calls into a unified interface layer to avoid being tightly bound to one provider’s billing measure, making it easier to integrate and migrate similar capabilities on platforms such as Baidu AI Cloud later.

    6. Conclusion

    The convergence of this billing measure essentially restores “retrieval” from a standalone product to a component of the inference chain. For developers, the real optimization focus shifts from “reducing retrieval calls” to “controlling context tokens.” Understanding token-based billing as a general measure and building an attributable cost observability system is the key to long-term control.