Cost Calculation for LLM Web-Connected Q&A: Comparing Two Integration Approaches

    This article breaks down the actual cost of LLM-powered web-connected Q&A by comparing two integration approaches: built-in web search (where the model handles retrieval) and a custom pipeline (where the developer calls separate search and scraping APIs). It clarifies that waiving tool-call fees does not eliminate token fees, provides a detailed cost model for 1,000 queries, and offers practical advice on budgeting, latency, and architectural decisions.

    When developers see announcements about “no charge for web search tool calls” from model providers, the immediate reaction is often “search is free.” But when the bill arrives, it becomes clear that only the tool invocation itself is free—the tokens consumed when the retrieved content is fed into the model are still billed at the standard rate. This article walks through the full cost calculation to help you avoid surprises when budgeting and choosing between integration architectures.

    Clarifying the Terminology: Tool Fees vs. Token Fees

    There are two typical ways to integrate web-connected Q&A, and their billing logic differs significantly.

    Approach 1: Delegating web search to the model. The model decides when to search and open web pages during generation. Under a policy that waives tool-call fees, this “invocation action” is not charged separately. However, the web content retrieved is added to the conversation context and participates in inference. All of that text is counted as input tokens and billed at the model’s standard input price. In other words, only the trigger action is “free”—every character read in is charged as usual.

    Approach 2: Programmatically calling search and scraping APIs. The developer first calls a search API to obtain a list of results, then calls a web scraping API to fetch page content, and finally assembles the material into the prompt for the model. In this scenario, search and scraping are independent services billed per successful request—a common industry price is around 5 RMB per 1,000 successful requests for both text search and web scraping, with failed, timed-out, or result-less requests not billed. Model inference costs are added on top of that.

    Therefore, judging whether web-connected Q&A is expensive requires looking beyond “input price per million tokens.” You must compare all costs—model fees, search fees, and scraping fees—on the same bill.

    Cost Estimate for 1,000 Built-in Web-Connected Queries

    Take a lightweight model with built-in web connectivity as an example. It has tiered pricing based on peak and off-peak hours (in RMB per million tokens): non-cache-hit input costs about 1 RMB off-peak and 2 RMB peak; cache-hit input costs about 0.02 RMB off-peak and 0.04 RMB peak; output costs about 4 RMB off-peak and 8 RMB peak. Peak hours typically refer to weekday business hours, while all other time is off-peak.

    Assumptions for the calculation: each task generates 6,000 non-cache-hit input tokens (including system prompts, retrieved web content, conversation history, and all other billable input) and 1,000 billable output tokens (including reasoning tokens). No retries and no additional billed services. For 1,000 tasks, the total is 6 million input tokens and 1 million output tokens. The built-in tool fee is 0. The model cost is:

    • Off-peak: 6 × 1 + 1 × 4 = 10 RMB
    • Peak: 6 × 2 + 1 × 8 = 20 RMB

    That translates to about 1 to 2 cents per query. Two critical details must be emphasized: first, the 6,000 input tokens represent the entire billable input for the whole task, not just the user’s initial question. In web-connected scenarios, retrieved documents often account for the bulk of the token count. Second, whether the model actually triggered a web search should be verified through the tool-call field in the invocation logs, not inferred from the answer content.

    Comparison with a Custom Search and Scraping Setup

    For the same model usage—6,000 input tokens and 1,000 output tokens—if you switch to a custom pipeline that calls search and scraping APIs, the bill has three parts:

    • Model inference fee: same as above—10 RMB off-peak, 20 RMB peak.
    • Search fee: assuming 1 search call per task, 1,000 calls cost about 5 RMB.
    • Scraping fee: assuming 2 page fetches per task, 2,000 calls cost about 10 RMB.

    The total is roughly 25 to 35 RMB, and if more pages are fetched per task, it is not surprising to reach 30 to 40 RMB. The gap between the two approaches does not come from model price differences but from the integration method: in the built-in mode the tool action is free but the retrieved tokens are consumed by the model; in the custom mode each external request costs real money.

    Scaling Up and Cost Elasticity Analysis

    A single-point estimate only answers “is it expensive?” Architectural decisions also require understanding how costs change with usage volume. Under a linear billing model, simply scale by unit prices:

    • Doubling the single-task input to 12,000 tokens doubles the model fee for 1,000 tasks (about 16 RMB off-peak, 32 RMB peak).
    • Expanding from 1,000 tasks to 100,000 tasks multiplies all fees by 100.
    • Cache hit rate is a key cost-saving lever: the price per cache-hit input token is roughly 1/50th of a non-cache-hit token. For scenarios with fixed system prompts and multi-turn conversations, carefully structuring the prompt prefix can significantly reduce input costs.

    Additionally, scheduling non-real-time tasks to off-peak hours can cut costs in half directly. Offline batch Q&A, nightly report generation, and similar workloads are naturally suited for off-peak execution.

    Practical Engineering Recommendations

    1. Set up per-line-item cost monitoring: Instrument and report model input/output tokens, search request counts, and scraping request counts separately. Aggregate at a daily level using logging services and monitoring alert tools to avoid discovering overspending at the end of the month.
    2. Control context length: Clean and truncate scraped web content, keeping only the paragraphs relevant to the question. This reduces cost and improves answer quality.
    3. Treat budgets as estimates, not commitments: The numbers above are based on publicly available pricing. Actual costs depend on real token usage, cache hit rates, and invocation timing. Before going live, conduct small-scale smoke tests to calibrate.
    4. Choose the integration method based on the scenario: For low-call-frequency, simple pipelines, prioritize built-in web connectivity to avoid the operational overhead of building a custom retrieval pipeline. For scenarios demanding strict control over retrieval quality and source traceability, consider a custom search and scraping setup—and include the tool fees in your budget.

    In summary: the waiver of tool fees applies only to the “action” of invoking the tool; token fees are always charged for the “content” that is processed. Put model fees, search fees, and scraping fees on the same spreadsheet, and calculate based on your own usage structure—that is the correct way to manage costs for web-connected Q&A.