LLM API Billing Evolution: Tool Calls Are Now Measured Only by Tokens

    This article explains a shift in LLM API billing where server-side web search and page fetching triggered by the model are no longer billed as separate items, with charges based only on token usage. It compares per-request and per-token billing models, outlines why a cloud provider would merge tool costs into inference pricing, and examines the impact on Agent and RAG applications. It also covers practical cost optimization techniques such as context compression, multi-level caching, controlling reasoning turns, and observability, along with architectural and engineering considerations.

    1. Background: From Per-Request Billing to Per-Token Billing

    A cloud provider disclosed a billing policy change in an official announcement: starting from a certain point in time, when developers call a large model and the model internally triggers server-side web search or page fetching, these tool-side costs will no longer be billed separately. The final bill reflects only the token consumption of the model itself.

    To understand the value of this announcement, it helps to reconstruct the previous billing model. Earlier, the platform launched two independent retrieval-related APIs: one accepted a query and returned a structured list of web results; the other accepted a single URL, fetched the page, and returned the title and body in Markdown format. Both APIs were built on the platform’s own retrieval and fetching pipeline, providing real-time web content for AI Agent and Retrieval-Augmented Generation (RAG) applications. Billing was based on the number of successful requests, with a public price of a certain amount in Chinese yuan per thousand successful requests.

    After the change, the billing basis shifted fundamentally: tool calls moved from an “independent SKU” back to an “ancillary capability of model calls.” Trigger conditions include using the web-enabled tool and calling its built-in web search tool through a compatible interface. In other words, as long as retrieval and fetching are initiated by the model’s own decision, users no longer pay separately for the tool side.

    2. Technical Differences Between the Two Billing Models

    Per-request billing and per-token billing correspond to completely different resource cost structures and produce different billing volatility characteristics.

    Per-request billing is highly predictable and decoupled from content length. A single fetch costs the same whether it returns three thousand words or thirty thousand words. Its risk is that “you pay even for invalid calls”: irrelevant retrieval results, page fetches that fail but are counted as successful, and repeated Agent retries all drive up the bill without delivering corresponding generation value.

    Per-token billing folds tool consumption into the context. Once retrieval results and page bodies enter the prompt, they naturally convert into input tokens; the answers the model generates based on this content are output tokens. Its advantage is that the bill correlates strongly with “actual inference load,” and it eliminates the separate metering and settlement pipeline on the tool side. The risk is that long pages can significantly inflate input tokens, and the cost of a single request may be dominated by retrieved content.

    An often-overlooked engineering fact is that regardless of the billing basis, retrieved content consumes tokens once it enters the context. The real difference between the two models is whether a separate fee is added on the tool side, and whether cost attribution is clear.

    3. Why Platforms Choose to Merge Billing

    From the platform’s perspective, this change has three motivations.

    First, it reduces billing complexity. Independent tool billing requires users to understand two metering units, two sets of quotas, and two billing statements, which creates a high cognitive burden. After merging, users only need to focus on one metric: tokens.

    Second, it encourages actual use of tool capabilities. When tool calls no longer incur additional marginal costs, developers are more willing to let the model decide autonomously whether to go online, improving the success rate and experience of Agent-type applications.

    Third, the cost structure itself is changing. The marginal cost of the retrieval and fetching pipeline is declining relative to inference compute costs. Absorbing tool costs into inference pricing is commercially simpler and makes it easier to apply unified caching, deduplication, and batching optimizations.

    4. Practical Impact on Agent and RAG Applications

    For RAG applications, the impact is neutral to slightly positive. Traditional RAG requires the application to maintain its own fetching and chunking pipeline, with costs mainly in storage and compute. When built-in retrieval on the model side becomes free, the barrier to hybrid retrieval (first querying a local knowledge base, then supplementing with real-time information from the web) is significantly lowered.

    For Agent applications, the impact is more pronounced. In multi-step reasoning tasks, the model may initiate retrieval multiple times within a single round. Under per-request billing, this was a bill amplifier; after merged billing, the main costs return to context length and the number of reasoning steps. This shifts the optimization focus from “reducing the number of calls” to “controlling context size and reasoning turns.”

    It is worth noting that costs have not disappeared; they have only changed form. If entire Markdown page bodies are stuffed into the context without trimming, input tokens may multiply, potentially hitting the context window limit and causing truncation, information loss, and degraded answer quality.

    5. Cost Optimization Practices

    First, compress retrieval results. After fetching, denoise the body text (remove navigation, ads, footers), then extract key passages by relevance, sending only the necessary fragments into the context.

    1. def build_context(pages, query, max_chars=4000):
    2. # pages: list of page texts obtained from fetching
    3. scored = []
    4. for p in pages:
    5. text = strip_boilerplate(p.text) # remove template noise
    6. score = relevance(text, query) # relevance scoring
    7. scored.append((score, text))
    8. scored.sort(key=lambda x: x[0], reverse=True)
    9. buf, total = [], 0
    10. for score, text in scored:
    11. if total + len(text) > max_chars:
    12. break
    13. buf.append(text)
    14. total += len(text)
    15. return "\n\n".join(buf)

    Second, build multi-level caching. Cache fetch results using “normalized query + target URL” as the key, combined with TTL and content hashes, to greatly reduce token inflation from repeated retrieval.

    Third, control reasoning turns. Set a maximum number of steps and timeouts for Agents to avoid infinite retrieval loops; route low-risk questions directly to the local knowledge base, and enable web access only for highly time-sensitive questions.

    Fourth, ensure observability. On the application side, log input/output tokens per request, the length of retrieved hit fragments, and cache hit rates to form a cost attribution dashboard, rather than only looking at the total bill.

    6. Architecture and Engineering Considerations

    Architecturally, it is recommended to encapsulate “retrieval capability” as a replaceable internal abstraction layer that hides whether the underlying implementation is a platform built-in tool or a self-built fetching service, making canary releases and fallback easier:

    1. Agent/Application Layer
    2. ↓
    3. Retrieval Abstraction Layer (unified interface: search(query) / fetch(url))
    4. ↓
    5. Built-in web tool | Self-built fetching cluster | Local vector store
    6. ↓
    7. Context Assembly (denoise / compress / rank / truncate)
    8. ↓
    9. Model Inference → Structured Output

    Engineering-wise, three points need attention. First, failure fallback: when retrieval is unavailable, fall back to the model’s internal knowledge and explicitly flag timeliness risks. Second, compliance and copyright: fetched content must respect target site terms and robots conventions, avoiding long-term storage and redistribution. Third, security boundaries: apply prompt injection protection to external web content, treat fetched text as untrusted input, and prohibit it from overriding system instructions.

    7. Conclusion

    The essence of this billing change is turning tool calls from an independent product into part of the inference service. The takeaway for developers is direct: the optimization focus shifts from “fewer calls” to “precise context.” Whoever can compress retrieved content more accurately, build finer-grained caching, and control reasoning turns more steadily will achieve lower real costs and higher answer quality under the same billing rules.