From Traffic to Tokens: Rewriting the Metering System for AI Services

    Traditional network services are metered by data volume, call duration, or bandwidth, but large language models are naturally metered by tokens, which correlate closely with compute consumption. This article explains why metering shifts from traffic to tokens, the four conditions for tokens to function as a business unit (orderable, convertible, payable, auditable), and how a unified gateway and intelligent routing help teams manage multi-model access, cost, and reliability.

    1. Why the Metering Unit Shifts from Traffic to Tokens

    Traditional communication services meter transmission volume: bytes of traffic, call minutes, and peak bandwidth. These metrics describe how much data moves through the pipe, but they correlate weakly with the value of the service content itself. Large model services are different. When a model processes text, it first splits the text into tokens and then computes over them one by one. The compute consumed by inference is approximately proportional to the number of input and output tokens, so tokens are a natural fit as the metering unit.

    A token is the basic discrete unit a model uses to process text; it is neither a character nor a word. Different languages and different tokenization schemes can split the same text into very different token counts, and the same business text may be metered differently on different models. Billing must therefore define the metering convention explicitly, or users cannot estimate their costs or compare prices across services.

    A common industry practice is to meter input tokens and output tokens separately, with different unit prices for each. The input portion mainly consumes compute for context encoding, while the output portion must be generated token by token, which typically takes longer and costs more. Understanding this distinction is the basis for estimating costs and designing prompt lengths and output limits.

    2. Four Conditions for Tokens to Become a Business Unit

    For a technical parameter to become a business unit, it must satisfy four conditions simultaneously: it must be orderable, convertible, payable, and auditable. Missing any one of them, metering stays at the technical level and cannot enter normal transaction and financial processes.

    Orderable means the metering unit has a clear product form, such as prepaid quota packages, periodic subscription plans, or pay-as-you-go postpaid billing. Users need to know how many tokens they are purchasing, the validity period, and which models the quota applies to.

    Convertible means there is a computable conversion relationship between the tokens of different models, and between tokens and other entitlements. Because each model has a different unit price, a unified quota pool needs a conversion coefficient for each model, distinguishing input consumption from output consumption. When conversion coefficients change, the effective time should be announced in advance.

    Payable means the settlement pipeline integrates with the financial system and supports refunds, reversals, and invoicing. Quota reservation and deduction must be transactional. If concurrent requests each read the balance before deducting, overspending can occur.

    Auditable means every call can be traced back to the specific model, timestamp, input and output token counts, and the calling principal. Itemized billing records are the basis for users to verify charges and for enterprises to allocate costs, and they serve as evidence when resolving disputes.

    3. Unified Access Layer: One Key for Multiple Models

    The most common engineering problem in a multi-model environment is fragmented integration. Each model service has its own endpoint, authentication method, and request format, so business code needs adaptation logic for every model. A unified access layer inserts a gateway between the business and the models, exposing a single endpoint and a single authentication scheme to the outside.

    The industry widely adopts designs compatible with common chat-completion-style interfaces, so business teams only need to change the model name to switch backends, significantly reducing migration cost. A unified key centralizes authentication at the gateway, making it easier to rotate keys, revoke them, and scope permissions by project.

    Below is sample integration code. The endpoint and key are read from environment variables rather than being written into code or configuration files:

    1. GATEWAY_BASE = read_env("LLM_GATEWAY_BASE")
    2. GATEWAY_KEY = read_env("LLM_GATEWAY_KEY")
    3. function chat(prompt, model, timeout=30):
    4. response = http_post(
    5. url = GATEWAY_BASE + "/chat/completions",
    6. headers = {"Authorization": "Bearer " + GATEWAY_KEY},
    7. body = {
    8. "model": model,
    9. "messages": [{"role": "user", "content": prompt}]
    10. },
    11. timeout = timeout
    12. )
    13. if response.status >= 400:
    14. raise error(response.status)
    15. return response.json()

    Keys should be assigned per project or per environment, following the principle of least privilege. Production keys must never appear in code repositories, logs, or screenshots. If a leak is detected, revoke the key immediately and issue a new one.

    4. Intelligent Routing: Matching Models to Task Types

    Not every task needs the most capable model. Tasks such as text classification, keyword extraction, and format conversion have modest capability requirements; small models usually achieve acceptable quality at a fraction of the cost of large models. Code generation and complex reasoning, on the other hand, require stronger models. The goal of intelligent routing is to find the balance among quality, cost, and latency for each request.

    There are three common routing strategies. The first is rule-based routing, which maps task labels directly to models; it is simple to implement and its behavior is predictable. The second is tiered routing, where a small model handles the request first and the system decides, based on confidence scores or output validation, whether to escalate to a larger model. The third is failover, which automatically switches to a backup model when the primary model times out or returns an error.

    Below is an example of rule-based routing:

    1. ROUTE_TABLE = {
    2. "classify": "small-model",
    3. "summarize": "medium-model",
    4. "code": "large-model"
    5. }
    6. FALLBACK = {
    7. "large-model": "medium-model",
    8. "medium-model": "small-model"
    9. }
    10. function pick_model(task_type, user_model=None):
    11. if user_model is not None:
    12. return user_model // Explicitly specified model takes priority
    13. return ROUTE_TABLE.