Large Model API Billing Optimization: How Search and Web Fetching Became Free
This article explains a recent change in which a cloud provider stopped charging separately for server-side search and web page fetching triggered inside a large model API call, while standalone retrieval and fetching APIs still bill per successful request. It breaks down which usage is free and which is still charged, shows how the cost model shifts from per-call pricing to token-based pricing, and presents practical techniques for controlling cost: context compression, layered caching and deduplication, restrained retry with fallback, observability and cost dashboards, and guidance on choosing between model-triggered retrieval and explicit API calls. A migration checklist is included.
1. What Changed: A Redraw of the Billing Boundary
A cloud provider has adjusted the billing rules for its large model API. Starting at 12:00 on November 18, server-side search and web page fetching triggered inside the model invocation chain are no longer billed separately. Developers pay only for the tokens actually consumed by the model. Standalone retrieval and fetching APIs are still billed per successful request, with a published example price of 5 CNY per 1,000 successful requests. Around the same time, the accompanying coding assistant and toolchain released pre-release versions that changed the default retrieval behavior.
This looks like a minor tweak on a pricing page, but it actually redraws the boundary of cost ownership. Network access used to be metered as an independent item; now it is folded into the token bill for model inference. The bill is simpler, yet the technical decision becomes more demanding: “free” covers only a specific trigger path, and calling the standalone APIs directly still costs money per request.
2. The Boundary You Must Understand: What Is Free and What Is Not
The key to this change is distinguishing two completely different call paths.
- Path A (model-triggered): The developer sends a single chat or inference request. During generation, the model decides on its own that external information is needed, the server performs retrieval and page fetching, and the results are merged into the context. Search and fetching on this path are not billed additionally.
- Path B (explicit capability call): The developer explicitly calls the retrieval or fetching API, obtains structured results, assembles the context, and then sends it to the model. This path is billed per successful request.
Three practical conclusions follow:
- Failed requests are not billed, so retry strategy directly affects the bill, not just latency.
- The billing anchor moves from call count to token usage, so long contexts and accumulated input tokens across turns become the main cost driver.
- Free does not mean zero cost. Extra context from retrieval and fetching pushes up input tokens; the cost simply moves to a different metric.
3. Restructuring the Cost Model: From Per-Call to Per-Token
Under the old model, cost was roughly requests × price per request. It was predictable, but bills ballooned in retrieval-heavy scenarios. Under the new model, cost is closer to:
total cost ≈ (input tokens + output tokens) × token price + successful standalone API calls × price per call
The optimization focus shifts from “call the API less” to “compress the context.” A full web page body stuffed into the context usually contains navigation, copyright notices, and repeated sections that waste tokens and dilute key information. Extracting the main content and summarizing it into structured form before adding it to the context is usually more economical than inserting the raw text.
Illustrative code (pseudo-implementation, conveying the idea only):
def build_context(query, raw_pages, max_chars=4000):kept = []for page in raw_pages:text = extract_main_content(page) # strip templates, ads, duplicatestext = normalize_whitespace(text)kept.append(text)merged = "\n\n".join(kept)[:max_chars] # hard budget to keep context boundedreturn f"Reference material:\n{merged}\n\nQuestion: {query}"
4. Caching and Deduplication: Pushing Repeated Cost Toward Zero
Real traffic for retrieval-augmented applications is often highly repetitive: the same hot questions and the same document pages are retrieved over and over. Adding layered caching is the highest-return step in cost governance.
- Semantic cache: vectorize the question and reuse a historical answer when a similarity threshold is met.
- Page cache: key on a page content fingerprint to avoid fetching the same page repeatedly.
- Result cache: cache retrieval results by “query + time window” to balance freshness.
def cached_lookup(query, ttl=600):key = fingerprint(query)hit = cache.get(key)if hit and not expired(hit, ttl):return hit.valuevalue = expensive_retrieve(query)cache.set(key, value, ttl=ttl)return value
Note that cache keys must include dimensions such as the time window and region or language. Otherwise stale or wrong-region results are returned, and such correctness defects are far more dangerous than spending a little more.
5. Reliability Design: Timeouts, Retries, and Fallback
Once billing is tied to failed requests, retries must be more restrained. Use exponential backoff with jitter and set a maximum retry limit. For non-critical paths, add fallback: when retrieval fails, fall back to the model’s internal knowledge and clearly label the answer as “not verified online.”
def with_retry(fn, retries=2, base=0.5):for i in range(retries + 1):try:return fn()except TransientError:if i == retries:return fallback_answer()sleep(base * (2 ** i) + random_jitter())
The fallback path must be surfaced explicitly in the product so users do not mistake model memory for real-time facts. In time-sensitive scenarios this is a necessary safety design.
6. Observability and Cost Governance
After the metric change, monitoring must change too. Collect at least: input/output token distribution, context length percentiles, cache hit rate, retrieval failure rate, number of fallback triggers, and cost per session. Make cost per session a core dashboard metric with budget alerts, so a traffic spike can be quickly traced to context bloat or a retry storm.
Architecturally, combine the stateless inference layer with common cloud capabilities such as caching, logging, and monitoring and alerting to achieve per-session cost attribution. A container platform can host elastic inference replicas, and object storage can hold historical context samples for offline analysis.
7. Selection Guidance: Model-Triggered vs. Explicit Calls
- Choose model-triggered: the need is to “supplement the latest information within a Q&A,” there is no requirement on result structure, and you want simple implementation and a predictable bill.
- Choose explicit calls: you need precise control over sources, cross-validation across multiple sources, reuse of retrieval results across downstream tasks, or structured output with fixed fields.
- Hybrid mode: the main path uses model-triggered retrieval, key fact verification uses explicit calls, and verification results are cached separately.
8. Migration Checklist
- Confirm the effective time of the billing change to avoid cross-date settlement disputes.
- Measure the context length distribution and set a hard budget and truncation strategy.
- Build a caching and deduplication layer with clear expiration conditions.
- Reduce retry counts and complete fallback and user-facing notices.
- Launch the cost dashboard and budget alerts.
- Add an explicit “verified online” indicator for time-sensitive scenarios.
Conclusion
The essence of this change is turning web retrieval from an independent product into an internal step of the inference chain. The bill is simpler, but control over cost depends more on engineering capability. Whoever compresses the context further, makes caching more accurate, and tightens retries will achieve a more stable cost curve and better answer quality under the same rules.
