LLM API Billing Shift: Why Search and Web Fetching Now Count as Tokens
This article explains a recent LLM API billing change in which server-side search and web fetching triggered inside a model call are no longer billed separately, while standalone search and fetch APIs still charge per 1,000 successful requests. It breaks down why the cost model moved to a token-only basis, how to estimate request cost with a token-based formula, and three engineering practices for keeping bills predictable: layered retrieval with on-demand triggering, context budgeting with snippet compression, and multi-layer caching. It also covers observability metrics, a canary-to-full rollout plan, and the broader shift from managing call volume to managing context budgets.
1. What Changed: From “Calls + Tokens” to Tokens Only
A cloud provider recently updated the billing rules for its LLM API. Starting at 12:00 on November 18, server-side search and web fetching triggered during a model call are no longer billed as separate line items. Developers pay only for the tokens the model actually consumes.
One important caveat: this change applies only to retrieval and fetching that are triggered automatically inside the model call chain. It does not cover search services or web fetching services offered as standalone APIs. Those are still billed per successful request, with a public price of 5 RMB per 1,000 successful requests. At the same time, a companion AI coding tool released a pre-release version that changed its default retrieval behavior.
On the surface, this looks like a small edit to a pricing page. In practice, it changes the marginal cost structure of retrieval-augmented (“connected”) applications. Previously, a single web-enabled question-and-answer request carried three cost components: model token fees, search call fees, and fetch call fees. After the change, search and fetching are folded into the token metric. Cost becomes far more predictable, but a new risk appears: token consumption can balloon because retrieved content is stitched into the context.
2. Why Search and Fetching Were Folded into Token Billing
From an implementation standpoint, server-side retrieval during a model call usually follows a “retrieve first, assemble context, then generate” flow. The retrieved page text is truncated, cleaned, and inserted into the prompt, which means retrieval and fetching results ultimately turn into tokens. Merging the two into token billing is essentially converting “intermediate process resources” into “final output resources.” The metric becomes more consistent, and developers no longer have to reconcile multiple metering dimensions.
For the platform, this reduces billing complexity and the number of disputes. For developers, it requires a new cost intuition: what really drives the bill is no longer “how many retrieval calls you made,” but “how much content you packed into the context.” The optimization focus therefore shifts from reducing call volume to controlling context size and hit rate.
3. Rebuilding the Cost Model: A Token-First Calculation
Developers can use the following formula for a rough estimate (illustrative only; it does not represent any specific provider’s official rules):
Cost per request ≈ (input tokens + output tokens) × unit priceInput tokens ≈ system prompt + user question + retrieved snippets + conversation historyRetrieved snippet tokens ≈ snippet count × average length per snippet
For example, if each retrieval returns 5 snippets of roughly 400 tokens each, retrieval alone adds about 2,000 input tokens per request. At 100,000 requests per day, that is roughly 200 million additional input tokens. Compared with the old linear growth of “retrieval calls × unit price,” growth under the token metric is tightly coupled to context design. Compressing snippet length and reducing snippet count therefore pay off much more than before.
4. Practice 1: Layered Retrieval with On-Demand Triggering
Not every question needs to go online. A three-layer chain is recommended:
- Local knowledge layer: search internal knowledge bases, caches, and vector indexes first.
- Server-side web layer: trigger only when local confidence is insufficient.
- Fallback generation layer: when no retrieval results exist, state the uncertainty explicitly instead of fabricating an answer.
A “does this need the web?” decision node can control the trigger ratio, for example:
def need_web_search(query, local_score):# Skip web search if local retrieval confidence is high enoughif local_score >= 0.82:return False# Time-sensitive keywords can force a web searchreturn any(k in query for k in ["latest", "today", "price", "release"])
After layering, the web trigger rate usually drops significantly while answer quality holds or improves, because local knowledge is typically a better fit for the business context.
5. Practice 2: Context Budgeting and Snippet Compression
Under token-based billing, the context budget is the core control. A “hard cap plus soft policy” approach is recommended:
- Hard cap: total retrieved snippet length per request should stay within a set proportion of the model’s context window (for example, 20%–30%).
- Soft policy: prioritize the title, first paragraph, and key conclusion sentences; compress the body with a summarization model.
- Deduplication: apply SimHash or MinHash to identical URLs and paragraphs so duplicate content does not eat into the budget.
Sample code:
def pack_snippets(snippets, max_tokens=1200):packed, used = [], 0for s in sorted(snippets, key=lambda x: x["score"], reverse=True):t = len(s["text"]) // 2 # rough token estimateif used + t > max_tokens:breakpacked.append(s)used += treturn packed
6. Practice 3: Caching Architecture
Caching is one of the most effective ways to cut costs. At least three layers are recommended:
- Exact cache: key on “normalized question + parameters” and return directly on a hit.
- Semantic cache: match similar questions via vector nearest-neighbor search with a similarity threshold.
- Retrieval cache: periodically refresh fetched and cleaned results for hot URLs to avoid repeated fetching.
Note that because standalone APIs bill per successful request, a failed retry itself does not incur a fee, though it consumes time and quota. Retries on the model side, by contrast, consume tokens again. The two strategies should be kept distinct: retrieval failures can be retried moderately, while generation failures should first be addressed by trimming the context before retrying.
7. Observability: Turning Tokens into Monitorable Metrics
The following metrics should be added to logging, monitoring, and alerting:
- Input/output tokens per request, snippet count, and average snippet length;
- Web trigger rate, cache hit rate, and retrieval success rate;
- Cost per request, daily cost, and budget watermark.
With these metrics in place, you can quickly pinpoint “why the bill went up” after a billing change. Common root causes include prompt template changes that lengthen the context, retrieved snippets that were never truncated, and conversation history without a sliding window.
8. Migration and Canary Rollout
Once the rule change takes effect, roll out in a “canary, compare, full” sequence:
- Canary: enable the new strategy for 5%–10% of traffic.
- Compare: measure average tokens, P95 latency, and answer adoption rate before and after the change.
- Full: ramp up only after both cost and quality targets are met, and keep a one-click rollback switch.
9. Conclusion
The key takeaway from this billing change is that cost control for retrieval-augmented applications is shifting from “managing call volume” to “managing context budgets.” Developers should treat layered retrieval, snippet compression, cache reuse, and observability as standard configuration. If an organization wants to build similar capabilities in its own environment, it can assemble a retrieval-augmented pipeline on general-purpose building blocks such as Baidu AI Cloud’s LLM platform, object storage, message queues, and monitoring and alerting, keeping costs under control and the architecture portable without depending on a single billing metric.
