Billing Model Shifts for LLM Web Search and Crawling: A Token Cost Estimation Guide

    This article explores the transition from per-request billing to token-based billing for LLM web search and crawling features. It compares the two pricing models, provides cost estimation methods, and outlines engineering best practices for controlling context expansion, optimizing costs, and ensuring compliance.

    Background: Adjusting the Billing Metric for Internet Connectivity

    When LLMs answer real-time questions or cite external resources, a common approach is to have the model invoke web search or crawling tools, inject the retrieved results into the context, and generate a response based on these contents. Previously, the costs for such invocations primarily came from two parts: the model’s own token consumption, and separate fees charged by the service provider for search and crawling requests.

    Starting November 18, 2026, a specific service provider’s adjustment rules are as follows: web search and crawling triggered by the server during model invocations will no longer be charged separately, but will be uniformly billed based on model token usage. Affected scenarios include built-in internet tools and search tool calls compatible with specific API formats.

    Previously, this service provider offered independent search and crawling APIs, billed per successful request at a rate of $5 per 1,000 successful requests. The search API returned structured results based on query terms, while the crawling API returned the title and main text (in Markdown format) of a single webpage.

    Although the billing metric has changed, the engineering costs associated with information retrieval have not disappeared. The original cost was primarily determined by the number of invocations, whereas now it depends on how many tokens the retrieved results consume. Understanding this is the prerequisite for accurate cost estimation.

    Essential Differences Between the Two Billing Models

    Token-Based Billing

    The total cost of token-based billing consists of two parts: input and output:

    1. Total Cost = Input Tokens * Input Unit Price + Output Tokens * Output Unit Price

    Search results and webpage contents returned by internet tools are usually fed back to the model as part of the context, thus counting toward input tokens. A crawled long webpage may contain thousands or even tens of thousands of tokens, directly driving up the cost of a single invocation.

    Per-Request Billing

    The total cost of per-request billing only relates to the number of successful requests:

    1. Total Cost = Successful Requests / 1000 * Unit Price per 1,000

    Under this model, the cost per invocation is fixed, regardless of the webpage length. However, webpage length still affects response latency and consumes the context window, indirectly impacting the model’s output quality.

    Comparison

    Dimension Token-Based Billing Per-Request Billing
    Cost Determinant Length and quantity of retrieved content Number of successful requests
    Cost Predictability Depends on content length, high volatility Fixed cost per request, easy to estimate
    Optimization Focus Content trimming, summarization, deduplication Reducing unnecessary calls
    Billing for Failed Requests Subject to billing rules Only successful requests are billed

    Neither method is absolutely superior; it depends on the average length of the webpages and the call frequency in your business.

    Cost Estimation Methods

    Assume the following values are for demonstration purposes only; refer to the official price list for actual pricing.

    Assume the per-request billing rate is $5 per 1,000 requests, i.e., $0.005 per request. Assume the input price for token-based billing is $2 per 1,000,000 tokens, and a crawled webpage averages about 4,000 tokens. A task requires crawling 5 webpages.

    • Token-based billing: 5 4,000 = 20,000 tokens. Cost is approximately 20,000 / 1,000,000 2 = $0.04.
    • Per-request billing: 5 fetches. Cost is 5 * 0.005 = $0.025.

    Under these assumptions, per-request billing is cheaper. If the average webpage is only 500 tokens, the token-based billing cost would drop to about $0.005, making it cheaper. Therefore, webpage length is the key variable determining which model is more cost-effective.

    You can use the following functions for a preliminary estimation:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class PriceConfig:
    4. input_per_million: float # Price per million input tokens, refer to official price list
    5. output_per_million: float # Price per million output tokens
    6. def estimate_token_cost(input_tokens: int, output_tokens: int, price: PriceConfig) -> float:
    7. """Estimate the cost of a single task based on token billing."""
    8. return (
    9. input_tokens * price.input_per_million
    10. + output_tokens * price.output_per_million
    11. ) / 1_000_000
    12. def estimate_request_cost(success_count: int, unit_price_per_1000: float) -> float:
    13. """Estimate cost based on per-request billing, counting only successful requests."""
    14. return success_count / 1000 * unit_price_per_1000

    In actual projects, it is recommended to use the tokenizer provided by the model service provider to count tokens, rather than roughly substituting character counts. The token conversion differences between Chinese and English are significant, so character count can only serve as a rough reference.

    Engineering Practices: Controlling Context Expansion

    Limiting Crawl Count and Total Context

    Agent-style applications often invoke multiple tools sequentially within a single task. Without constraints, the context grows with each crawl, causing costs and latency to rise simultaneously. You can set a budget cap for each task:

    1. class ToolBudget:
    2. """Crawl budget control within a single task."""
    3. def __init__(self, max_fetches: int = 5, max_context_tokens: int = 24000):
    4. self.max_fetches = max_fetches
    5. self.max_context_tokens = max_context_tokens
    6. self.fetch_count = 0
    7. self.context_tokens = 0
    8. def allow_fetch(self) -> bool:
    9. return (
    10. self.fetch_count < self.max_fetches
    11. and self.context_tokens < self.max_context_tokens
    12. )
    13. def record(self, page_tokens: int) -> None:
    14. self.fetch_count += 1
    15. self.context_tokens += page_tokens

    When the budget is exhausted, the application should have the model provide an answer based on existing information, or inform the user that information is insufficient, rather than continuing to crawl indefinitely.

    Trimming Webpage Content

    Webpages often contain navigation bars, advertisements, footers, and recommendation links. These contents are irrelevant to the query but consume tokens. Cleaning and truncating the content after crawling can significantly reduce the input size. The following example is a simplified version that truncates by character count:

    1. def truncate_markdown(text: str, max_chars: int = 8000) -> str:
    2. """Truncate webpage content by character count and retain a notification."""
    3. if len(text) <= max_chars:
    4. return text
    5. return text[:max_chars] + "\n\n[Content truncated]"

    A better approach is to split the text based on heading levels first, retaining only the paragraphs relevant to the query before passing them to the model. This semantic filtering can be accomplished using general techniques like vector retrieval.

    Caching and Deduplication

    When the same query term or URL is repeatedly requested within a short period, results should be reused. Common practices include:

    • Using the query term or normalized URL as a key to cache results with a reasonable expiration time;
    • Deduplicating similar queries within the same task to prevent the model from repeatedly searching the same topic;
    • Pre-processing high-frequency, stable-content pages offline and storing them in a database to reduce real-time crawling.

    Prompt Constraints

    Explicitly define tool usage rules in the system prompt, such as requiring the model to assess whether its internal knowledge is sufficient first, invoking internet tools only when necessary, and prioritizing search summaries over full-page content. The cost of prompt constraints is practically zero, yet they effectively reduce invalid calls.

    Monitoring and Cost Governance

    Cost optimization requires data support. It is recommended to log the following metrics for each tool invocation:

    • Invocation time, associated task ID, and tool type;
    • Number of input and output tokens;
    • Character count of the crawled webpage and the difference before and after truncation;
    • Request success status and duration.

    This data can be integrated into a logging service and aggregated by day, application, and task type in a dashboard. When daily usage or single-task cost exceeds a threshold, trigger a monitoring alert to notify the responsible party. Before going live, it is advisable to conduct a comparative test using real traffic, calculating the costs under both billing metrics to determine the default strategy.

    Compliance and Risk Warnings

    When retrieving information from the web, note the following:

    1. Comply with the target website’s crawling rules, such as checking its robots.txt protocol and respecting site access restrictions;
    2. Be mindful of copyright issues. When crawled content is used for model inference and generating summaries, avoid directly forwarding or redistributing large sections of the original text;
    3. Webpages may contain personal information; desensitize this data before writing it to logs or caches;
    4. Billing rules may change at any time. Do not hardcode the unit price at a specific point in time in your code. Manage it through configuration and regularly verify against billing statements.

    Conclusion

    After shifting from independent per-request billing to token-based billing for web search and crawling, the core variable of cost moves from invocation count to the length of retrieved content. Developers should first estimate the average token size of webpages and then choose an appropriate strategy: control invocation counts through budget caps, compress inputs through trimming and filtering, reduce duplicate requests through caching, and continuously validate optimization effects using monitoring data. These practices are vendor-agnostic and applicable to most model-based Agent and RAG applications.