Recalculating Costs When Search and Web Crawling are Billed as Tokens

    As platforms merge server-side search and web crawling fees into a unified model token billing system, developers must rethink cost estimation. While separate search charges are eliminated, search results are billed as input tokens. This article breaks down the new billing model, compares old and new cost formulas, provides a calculation example, highlights the risk of context bloat, and offers architectural strategies to manage input token consumption.

    Conclusion

    A recent platform announcement states that server-side search and web scraping will no longer be billed separately. Instead, these costs are unified into model token usage. While search fees are indeed eliminated, search results enter the model as context, and this content is billed as input tokens. Developers must recalculate their expected input tokens, not just the output tokens.

    This article uses a hypothetical platform as an example, and all prices are illustrative. For actual unit prices, effective dates, and billing metrics, please refer to the official pricing page and your billing statements.

    1. Why Change the Billing Model?

    AI Agents and RAG applications require real-time web information. Early approaches billed search, scraping, and model generation separately. An Agent task might invoke tools multiple times, with each invocation generating its own fees, making the total cost of a single session difficult to predict.

    By unifying billing into a token-based metric, the bill has only one dimension. Developers no longer need to estimate usage across multiple channels; they only need to monitor token consumption. This approach also aligns more closely with the actual resource consumption of the model, as search results ultimately pass through the model for reading and reasoning.

    2. Old vs. New Cost Formulas

    Under the old model, the cost of a single call involving search consisted of three parts:

    • Search fee: (Number of searches / 1000) × Price per 1,000 searches
    • Input fee: (Input tokens / 1000) × Input price per 1,000 tokens
    • Output fee: (Output tokens / 1000) × Output price per 1,000 tokens

    Under the new model, the search fee is zero, and the calculation for the other two remains unchanged:

    Total cost per call = (Input tokens / 1000) × Input price + (Output tokens / 1000) × Output price + Additional surcharges (if specified by the platform)

    Here, input tokens include the system prompt, user query, conversation history, as well as the full content of search results and scraped pages. Focusing solely on output tokens will lead to underestimating costs.

    3. A Calculation Example

    Assume a RAG application triggers one search per query and concatenates the results into the context. The following conditions are hypothetical examples:

    • Old model search price: $5 / 1,000 searches
    • Input price: $0.004 / 1,000 tokens
    • Output price: $0.01 / 1,000 tokens
    • System prompt and user query: 300 input tokens
    • Search results injected into context: 1,500 input tokens
    • Model output: 800 output tokens
    Item Old Model New Model
    Search fee $0.005 $0.00
    Input fee (1,800 tokens) $0.0072 $0.0072
    Output fee (800 tokens) $0.008 $0.008
    Total cost per call $0.0202 $0.0152

    Under these assumptions, the new model saves about $0.005 per call, a reduction of roughly 25%. What is saved is the fixed search fee; the input token fee for the search results still applies.

    The real risk lies in context bloat. In the new model, search appears to be free, making it easy for teams to relax limits on the number of search results or expand scraping ranges. Using the prices in the table above, bringing in an extra 1,250 input tokens in the new model would offset the saved search fee, bringing the total cost back to the old model’s baseline. The calculation is: $0.005 / $0.004 per 1,000 tokens = 1.25k tokens.

    Fetch interfaces often return full-page Markdown content, and a single page can amount to thousands of tokens. If an Agent scrapes full pages every turn, the input tokens will quickly exceed this threshold. Whether the platform genuinely saves money depends on how well the team can control context length.

    4. Billing Boundaries to Verify with the Platform

    The official pricing page usually provides definitive answers. Before budgeting, confirm the following questions one by one:

    1. Are search results and scraped content returned by tools billed as input tokens, or is there a separate pricing rule for tool results?
    2. Are the unit prices for input and output different? Most token-billed platforms distinguish between the two, with output prices typically being higher.
    3. Are there cache discounts for repeated context? If the same search result is sent repeatedly across multiple conversational turns, is the cache hit price lower than the standard input price?
    4. Are failed searches, empty results, or timed-out requests counted toward tokens or other fees?
    5. Do quotes include taxes? Are there minimum spends, rate limits, or concurrency-related fees?

    Do not plug hypothetical numbers directly into your budget sheet before verifying these details.

    5. Architecture Design: Control Input, Not Just Output

    Many optimization tips emphasize compressing output length, but in search scenarios, the input context is the primary variable. It is recommended to set limits from the following aspects:

    • Maximum number of results returned per search, e.g., up to 5.
    • Maximum summary length retained per result, e.g., no more than 300 characters.
    • Maximum number of searches allowed per task, e.g., up to 3.
    • Maximum input token budget per task; if exceeded, stop retrieving and generate an answer based on existing information.
    • Before scraping a page, filter using search snippets and only scrape pages that are strictly necessary.

    Below is pseudocode illustrating the control logic. In actual use, you need to replace it with the platform’s SDK and add error handling.

    1. # Pseudocode: Illustrating budget control logic only
    2. MAX_RESULTS = 5
    3. MAX_SNIPPET_CHARS = 300
    4. MAX_SEARCHES = 3
    5. MAX_INPUT_TOKENS = 8000
    6. def answer(question):
    7. context = []
    8. input_tokens = count_tokens(question) # Pseudo-function: count tokens
    9. searches = 0
    10. while searches < MAX_SEARCHES and input_tokens < MAX_INPUT_TOKENS:
    11. results