LLM Calls with Web Search: Cost Breakdown and Budget Control
This article explains how billing works for LLM tasks that use web retrieval, including tool-call fees and context token fees. It provides a cost formula, identifies the main cost drivers, lists common billing units and control levers for search, page fetching, and document parsing, and outlines how multi-round model calls accumulate input tokens. It also presents illustrative pricing assumptions for budgeting calculations.
1. Billing Components and Scope
A task that combines LLM inference with web retrieval typically produces a bill with two parts:
- Tool-call fees: Search, web page fetching, document parsing, and similar tools are billed per call or per unit.
- Context token fees: Input tokens read by the model for each inference and output tokens generated by the model are billed by volume.
The cost of a single task can be expressed as:
Cost per task = Σ (number of searches × price per search) + Σ (pages fetched × price per page) + Σ (input tokens per model call × input token price + output tokens per model call × output token price)
The last summation corresponds to each model call within one task.
Three variables determine the size of the bill: retrieval rounds, pages fetched, and the length of text that enters the context. The following table lists common tools, their billing units, and controllable levers. Specific billing units are subject to the provider’s documentation.
| Tool | Billing unit | Trigger condition | Main control levers |
|---|---|---|---|
| Web search | Per search | Model decides to call the search tool | Maximum tool-call rounds; tool allowlist |
| Web page fetch | Per page | Model decides to fetch a URL | Limit pages fetched; prioritize summary pages |
| Document parsing | Per page or per file | User uploads or references a document | Limit page count; parse on demand |
Three points require attention:
- Unit prices are for reference only. Budgets should follow the provider’s billing terms. Prices vary by provider and over time.
- Retrieval rounds are decided by the model during reasoning and are not a request parameter. The caller usually cannot directly specify the number of rounds, but can indirectly control them through maximum round limits, tool parameters, prompt constraints, and budget thresholds. The model still decides within those constraints whether to continue retrieving.
- Context token fees include the system prompt, conversation history, retrieval results, fetched page body, and model output.
2. Illustrative Calculation
In multi-round calls, the model re-reads all previous context in each round. Input tokens must therefore be accumulated per model call, not counted only once.
An illustrative calculation would use the following assumptions. These figures are for demonstration only and do not represent any provider’s pricing.
- Base prompt (system prompt plus user question): 2,000 tokens
- Search and fetch results appended per round: 1,500 tokens
- Model output per round (tool-call decision): 300 tokens
- Final answer output: 800 tokens
- Unit price assumptions: CNY 0.01 per search, CNY 0.005 per page fetched, CNY 2 per million input tokens, and CNY 8 per million output tokens
