Simplifying LLM API Billing: 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 charged per request but are instead merged into token usage. It covers why per-call pricing created obstacles for AI agent adoption, offers a calculable comparison of the old and new cost models, and outlines five engineering practices—token-based budgets, layered caching, graceful degradation, context allocation, and observability—needed to keep costs predictable. It also addresses capability boundaries, compliance constraints, and the broader industry move toward built-in capabilities.

    1. What Changed: From Stacked Billing Back to a Single Meter

    A cloud provider’s LLM service introduced new billing rules effective November 18 at 12:00. Server-side web search and page fetching triggered during model calls are no longer charged separately per request. Instead, they are now folded into the model’s token usage. Previously, this capability was offered as a standalone interface priced per successful request (roughly 5 RMB per 1,000 calls), covering multiple trigger points such as the native web tool and search tools compatible with mainstream third-party interface specifications.

    The key point of this change is not a “price cut” but the convergence of the metering dimension: external information retrieval has been collapsed from an independent value chain into the main model-call pipeline, becoming a baseline capability rather than an add-on plugin.

    2. Why Per-Call Billing Became a Barrier to Agent Adoption

    The typical form of an agent application is a “think—retrieve—think again” loop, where a single user query often maps to multiple rounds of external information retrieval. Per-call billing introduced three problems in the cost structure:

    1. Unpredictable cost: The number of retrievals in a single turn is decided dynamically by the model, making it hard for developers to give a stable estimate at the quoting stage.
    2. Misalignment between cost and output: A single fetch may return many low-relevance pages, yet the fee is settled per “successful request,” causing the input-to-output ratio to spiral out of control.
    3. Distorted architecture: To save money, developers artificially cap retrieval rounds or move retrieval to the client side, sacrificing the quality of the model’s autonomous decision-making.

    After merging into the token model, retrieval consumption and text consumption share the same source and pool. Cost varies linearly with context size, and predictability improves significantly.

    3. Rebuilding the Cost Model: A Calculable Comparison

    Let the average number of retrievals per turn be n, the tokens injected into context per retrieval be t, and the model input price be p_in.

    • Approximate old cost: C_old ≈ n × c_call + n × t × p_in
    • Approximate new cost: C_new ≈ n × t × p_in

    The difference is n × c_call. In high-frequency retrieval scenarios (such as n≥3), this fixed stacked overhead is often the primary cost item. More importantly, C_new depends only on context length, so developers can directly and linearly adjust the bill by controlling the volume of injected content.

    Note that “no separate charge” does not mean “free”: fetched content still consumes tokens once it enters the context. Long pages, repeated fetches, and full-text injection all inflate the bill. The focus of cost governance shifts from “call fewer times” to “inject less.”

    4. Engineering Implementation: Five Design Areas You Must Cover

    1. Retrieval Budget and Round Limits

    Set a token budget per session rather than a call-count budget. When the budget is exceeded, switch to “answer based only on existing context” and explicitly inform the user.

    2. Layered Caching

    Cache results keyed by normalized URL, combined with a digest cache (compressing the body into a fixed token range), to significantly reduce context bloat from repeated fetches.

    1. def fetch_with_cache(url, ttl=3600, max_tokens=800):
    2. key = normalize(url)
    3. hit = cache.get(key, ttl=ttl)
    4. if hit:
    5. return hit
    6. raw = fetcher.grab(url) # server-side fetching capability
    7. digest = summarize(raw, max_tokens=max_tokens)
    8. cache.set(key, digest, ttl=ttl)
    9. return digest

    3. Failure and Fallback Paths

    Treat fetch failures, timeouts, and anti-scraping blocks as normal branches: retries should use exponential backoff, with a final fallback to “answer without external information” or “switch to a backup source” to avoid a pipeline avalanche.

    4. Context Budget Allocation

    Set a fixed ratio for “system instructions + conversation history + retrieval evidence + output reserve.” When retrieval evidence exceeds the limit, truncate by relevance rather than compressing proportionally.

    5. Observability

    Instrumentation should cover at least: retrieval rounds per session, injected token volume, cache hit rate, fetch failure rate, and end-to-end latency. These five metrics form the cost and quality baseline for web-connected applications.

    5. Capability Boundaries and Compliance Constraints

    Server-side search and fetching solve the “information acquisition” problem, not the “information trustworthiness” problem. Engineering practice should insist on: traceable citations, presenting conflicting evidence side by side, and labeling the fetch time for time-sensitive content. It should also respect the target site’s access terms and robots protocol, and control concurrency and frequency to avoid putting pressure on external sites.

    6. Trend Outlook

    Unifying the billing standard signals the industry’s move from “selling interfaces” to “building in capabilities.” When retrieval becomes a standard baseline of the model, the competitive focus returns to retrieval quality, context utilization efficiency, and agent planning capability itself. For developers, the most worthwhile investment right now is not driving down unit price, but turning caching, budgets, fallback, and observability into standard components—this determines how deep an application can take web-enhanced capabilities under the premise of predictable cost. If you use relevant Baidu AI Cloud products to host such applications, you can combine object storage for evidence archiving, message queues for smoothing fetch tasks, and logging and monitoring/alerting services to build a cost dashboard, forming a complete engineering loop.