Large Model API Billing Simplification: Search and Web Fetching Folded into the Token Model
This article examines a shift in large model API billing where server-side search and web fetching are no longer charged separately and are instead covered by model token usage. It explains why per-call pricing becomes a cost bottleneck for agents, presents the math behind the move to a single cost variable, and outlines five engineering practices: layered retrieval, context compression, caching and reuse, budget guardrails with observability, and structured results. A reference architecture and key risks are also included. Developers building web-connected AI applications can use these general methods to redesign their architecture and cost model.
1. What Changed: From Dual-Track to Single-Track Billing
A cloud provider’s large model platform announced an API billing change: starting November 18 at 12:00, server-side search and web fetching triggered during model calls are no longer billed separately. Instead, everything is settled based on model token usage alone. Previously, the platform had launched standalone retrieval and fetching interfaces on October 17 of the same year, backed by its in-house search engine and priced per successful request at 5 CNY per 1,000 calls. Under the new policy, both capabilities are merged into the standard call path and treated as part of the base offering, covering native web tools, search tools compatible with mainstream Anthropic-style interfaces, and search tools in response-based interfaces.
This article does not evaluate any specific vendor product. Instead, it abstracts the change into a general technical question: when external information retrieval moves from a standalone add-on to a built-in stage of model invocation, how should developers restructure the architecture and cost model of web-connected applications?
2. Why Per-Call Pricing Becomes a Cost Bottleneck for Agents
The biggest difference between an AI agent and a traditional question-answering system is autonomy: the model decides on its own whether retrieval is needed, how many rounds to run, and which pages to fetch. This creates three cost characteristics:
- Unpredictable call volume: A single user question may trigger multiple “retrieve, read, retrieve again” loops, and request counts grow non-linearly with task complexity.
- Weak correlation between cost and output: Under per-call pricing, a noisy retrieval result and a precise hit cost the same, so developers pay for trial and error.
- Pronounced stacking effects: Retrieval fees, fetching fees, and token fees are settled in parallel, making the bill complex and unit economics hard to calculate.
Once retrieval is folded into the token model, the cost variables converge to one: context length. This simplifies billing and shifts the optimization focus from “fewer requests” to “controlling context size and reuse rate.”
3. The Math Behind the Billing Model Change
Under the old model, total cost was:
Cost_old = α * TokenIn + β * TokenOut + γ * SearchCalls + δ * FetchCalls
Under the new model:
Cost_new = α' * (TokenIn + TokenRetrieved) + β * TokenOut
Here, TokenRetrieved is the additional input tokens created when retrieved and fetched content is injected into the context. Two conclusions matter:
- The fixed cost terms (γ, δ) disappear, and marginal cost depends only on the volume injected into the context.
- The optimization goal shifts from “call less” to “inject less, reuse more,” meaning higher information density per token.
4. Engineering Practice: Five Optimization Techniques
4.1 Layered Retrieval and On-Demand Triggering
Do not enable full web access by default. A three-tier strategy is recommended: first let the model decide whether external information is needed; when it is, prefer a low-cost cache or summary layer; trigger real-time retrieval only when timeliness requirements are high.
4.2 Compress Context Instead of Stacking Raw Text
Fetched pages often contain navigation, ads, and boilerplate. Before injection, perform main-content extraction, deduplication, and summarization to compress a “full page” into “key points plus source markers.”
def build_context(query, docs, budget=1500):docs = sorted(docs, key=lambda d: d.score, reverse=True)picked, used = [], 0for d in docs:brief = summarize(d.text, max_tokens=200)if used + brief.tokens > budget:breakpicked.append(brief)used += brief.tokensreturn picked
4.3 Caching and Reuse
Build a semantic cache for high-frequency queries, keyed by vector similarity rather than string matching, with a clear expiration window. Knowledge queries that are not time-sensitive typically have high hit rates and are the first choice for cost reduction.
4.4 Budget Guardrails and Observability
Set limits on retrieval rounds and context tokens per session. At the same time, feed token consumption, retrieval trigger rate, and cache hit rate into logging and monitoring with alerts, forming a tunable metrics system.
4.5 Structured Results
Have retrieval results enter the context as structured snippets (title, key points, timestamp, source). This improves answer traceability and reduces the token overhead of the model’s secondary reasoning.
5. Reference Architecture
User request→ Intent detection (is external information needed?)→ Cache layer (return directly on a semantic hit)→ Retrieval/fetching (built-in server-side capability)→ Cleaning and summarization (main-content extraction + compression)→ Context assembly (budget control)→ Model inference→ Logging and metrics reporting (tokens, hit rate, rounds)
6. Risks to Watch
- Cost does not disappear; it moves: Long contexts drive up input tokens, and without compression the bill may rise rather than fall.
- Context pollution: Injecting too much low-quality content can cause hallucinations and instruction conflicts, so source credibility should be graded.
- Reproducibility: Real-time retrieval results change over time, so test and production behavior may differ; keep snapshots for regression.
- Compliance and copyright: Fetched content must respect target site terms and robots conventions, and caching or redistribution must not overstep.
7. Conclusion
Folding search and fetching into token billing turns web capability from an add-on product into a base resource, lowering the entry barrier and billing complexity for web-connected AI applications. For developers, the real benefit is not “free” usage but a single, predictable cost model. Whether that benefit materializes depends on establishing engineering discipline around layered retrieval, context compression, cache reuse, and budget guardrails. If you use the relevant model services from Baidu AI Cloud, it is also advisable to run small-scale load tests with the general methods above before gradually scaling up.
