LLM Web Search Billing Changes: Cost Accounting and Scheduling Strategies
This article explains how to compare per-call search fees with token costs when an LLM provider changes its web search billing. It covers a cost model, a worked example, the break-even condition for search result backfilling, and off-peak scheduling for offline tasks.
1. Background
Large language models have moved beyond generating text. They now call external tools on their own to get real-time information. Web search is one of the most common tools. After receiving a question, a model may search first, fetch web pages, and then keep searching based on what it reads. Sometimes this loop runs more than ten rounds before the model gives an answer. The cost of such a task has two parts: the fee for the tool calls themselves, and the model input fee for the search results written into the context.
When a provider changes its billing rules, it often changes how one of these parts is charged. The bill may show one line item fewer, but the total cost may not fall by the same amount. To judge whether a price change is favorable, compare both parts in the same cost model.
2. Differences Between the Two Billing Methods
Per-call billing scales linearly with the number of calls. Each search or fetch is a distinct billable event. Developers can count calls in code, and costs are predictable. However, the more calls a task makes, the higher the cost.
Token-based billing depends on the volume of content. After search results enter the context, they are billed as input tokens along with the prompt and conversation history. Longer pages and more search rounds make the context larger, so the input cost of every inference step accumulates.
The core difference is this: per-call cost is driven mainly by how many calls are made, while token-based cost is driven mainly by how much content the model reads. If a batch of web pages contains the same amount of text, it produces the same number of input tokens. The cost of that content exists no matter which line item it is billed under.
Who Triggers the Search Determines Cost Control
Another factor is easy to overlook: who decides to search. When the program calls the search API explicitly, the number of calls is fully under code control, and developers can set a cap. When the model decides on its own when to search, the number of rounds depends on the model’s judgment. Developers can only constrain it with a budget limit and a maximum number of rounds. The same billing rules carry different cost risks under these two trigger methods.
3. Cost Estimation Model
Split the total cost of a task into three items:
Total cost = search call fee + input token fee + output token fee
where:
- Search call fee = number of searches ÷ 1,000 × price per 1,000 searches
- Input token fee = number of input tokens ÷ 1,000,000 × price per million input tokens
- Output token fee = number of output tokens ÷ 1,000,000 × price per million output tokens
The code below shows the calculation. Unit prices and billing periods follow the provider’s published rules. The values here only demonstrate the method.
def estimate_cost(search_calls, input_tokens, output_tokens, prices):"""Estimate the cost of a single task. Unit prices in prices are set by the provider's rules."""search_cost = search_calls / 1000 * prices["search_per_k"]input_cost = input_tokens / 1_000_000 * prices["input_per_m"]output_cost = output_tokens / 1_000_000 * prices["output_per_m"]return search_cost + input_cost + output_cost# The unit prices below are hypothetical values for demonstration onlyold_rule = {"search_per_k": 10, "input_per_m": 1, "output_per_m": 4}new_rule = {"search_per_k": 0, "input_per_m": 1, "output_per_m": 4}# Old rule: 30 searches, 200,000 input tokens, 40,000 output tokenscost_old = estimate_cost(30, 200_000, 40_000, old_rule)# New rule: searches are free, but backfilling search results adds 150,000 input tokenscost_new = estimate_cost(30, 350_000, 40_000, new_rule)
A Worked Example
The following numbers are hypothetical. They illustrate the calculation and do not reflect any real pricing. Consider a medium-sized task with 30 searches, 200,000 input tokens, and 40,000 output tokens. Assume a price of 10 yuan per 1,000 searches, 1 yuan per million input tokens, and 4 yuan per million output tokens.
- Under the old rule, the search fee is 0.30 yuan, the input fee is 0.20 yuan, and the output fee is 0.16 yuan, for a total of 0.66 yuan.
- Under the new rule, the search fee is zero. However, backfilling adds 150,000 input tokens, which raises the input fee to 0.35 yuan. The total is 0.51 yuan, about 23% lower.
This result depends on specific conditions. When the search fee is removed, the saved amount must be compared with the input fee for the backfilled content. The break-even condition is:
Incremental backfilled tokens × input unit price ≤ number of searches × fee per search
Applying the example, the search fee is 0.30 yuan and the input price is 1 yuan per million tokens, so the break-even backfill volume is 300,000 tokens. The new rule is cheaper as long as the actual incremental backfill stays below that value. To judge whether a price change helps, measure the average number of tokens each search backfills. The price table alone is not enough.
4. Time-of-Use Pricing and Off-Peak Scheduling
Some providers charge different prices at different times. For example, working hours may use peak prices, while nights or public holidays use off-peak prices. This follows the same idea as scheduling cloud resources by time. Prices are high when resources are scarce and low when they are idle, so price signals shift demand.
Developers can split tasks into two categories:
- Real-time tasks: users wait online for results, such as conversational Q&A and interactive assistants. These tasks cannot be moved to off-peak hours.
- Offline tasks: results can be retrieved later, such as batch crawling, overnight report generation, and weekend data cleaning. These tasks can be scheduled.
Let r be the share of total tokens that come from offline tasks, and let the off-peak unit price be k times the peak unit price, where 0 < k < 1. Assuming all unit prices drop by the same proportion, the overall cost reduction is r × (1 − k). For example, with r = 0.6 and k = 0.5, the overall cost falls by 30%.
When scheduling, read the time-window rules from configuration rather than hardcoding them. Peak windows and holiday rules change when providers adjust their pricing.
from datetime import datetime# Load the time-window configuration from an external source so it can change with the pricing rulesOFF_PEAK_CONFIG = {"peak_windows": [(9, 12), (14, 18)], # Weekday peak hour ranges (example)"weekend_is_off_peak": True,}def is_off_peak(now: datetime, config: dict = OFF_
