Multi-Model AI Assistant Architecture: Design and Cost Governance Practices

    This article explains how to design a multi-model AI assistant platform with separate model gateway, capability routing, and metering and billing layers. It covers unified request handling, authentication, retries, rate limiting, error-code mapping, context-window constraints, a multiplier-based cost model, free-quota deduction order, and discount application, with an example multiplier table and settlement code.

    Background: From a Single Model to a Multi-Model Matrix

    Over the past few years, many AI assistant products have built their capabilities around a single in-house large model. As model iteration accelerates, the strengths of different models have begun to diverge. Lightweight tasks, such as rewriting short sentences or organizing meeting notes, place more emphasis on response speed and per-call cost. Complex reasoning tasks, such as breaking down multi-step plans or reviewing long code, depend more on the model’s depth of understanding.

    As a result, a common platform approach is to offer both in-house Lite and Pro versions while integrating several external model services. Different versions vary in parameter scale, context-window length, and price. More model choices make cost judgment harder for users. This article explains, from the perspectives of architecture, billing, and discounts, how to keep the rules of a multi-model platform transparent and controllable. All numerical values in this article are examples; actual rules are subject to the platform’s published policies.

    1. Architecture Layers for Multi-Model Access

    To reliably provide multiple models through a single entry point, a platform generally needs three layers: a model gateway layer, a capability routing layer, and a metering and billing layer. Once responsibilities are separated, replacing or adjusting one layer usually does not require changing the core logic of the other layers.

    1.1 Model Gateway Layer

    The gateway layer masks protocol differences between models. Whether the underlying service uses streaming or non-streaming output, and whether it supports tool calls, the gateway should expose the same request and response format to upper layers. Below is an example of a unified request body:

    1. {
    2. "model_id": "lite-v1",
    3. "messages": [{"role": "user", "content": "Summarize this meeting transcript in three sentences."}],
    4. "stream": true,
    5. "timeout_ms": 30000,
    6. "max_retries": 2
    7. }

    The gateway also needs to handle the following engineering concerns:

    • Authentication: Each request carries an access token, which is validated at the gateway. Keys are stored in a key management service and are not written into code or logs.
    • Timeouts and retries: Set an overall timeout. Retry only retryable errors, such as connection interruptions or upstream 5xx responses, a limited number of times, and use exponential backoff to avoid amplifying upstream pressure.
    • Rate limiting: Limit requests per second by user and by model to prevent a single user from consuming the capacity of a particular model.
    • Unified error codes: Map errors returned by different upstreams to the platform’s own error codes. For example, QUOTA_EXHAUSTED means that both the free quota and paid balance are insufficient, and MODEL_UNAVAILABLE means that the model is temporarily unavailable. The frontend only needs to handle platform error codes.
    • Response encapsulation: Streaming responses are pushed chunk by chunk, while non-streaming responses return the complete result. Both modes include model_id and usage fields for the billing layer.

    1.2 Capability Routing Layer

    The routing layer recommends or restricts available models based on three types of information: task type, such as summarization, code assistance, or long-form writing; the context window required by the input length; and the user’s current quota status.

    The context window is a hard constraint. When the input exceeds the window limit of a model, that model should not appear in the selectable list. Parameter scale and capability tier are soft constraints. The routing layer can make recommendations based on them, but the final choice should be left to the user.

    1.3 Metering and Billing Layer

    The metering and billing layer is the most easily overlooked, yet it directly determines how users perceive the platform. It needs to answer three questions: how much this call consumed, how much free quota remains, and whether any discount applies. These are explained below.

    2. Multiplier System: Making Costs Comparable

    The inference costs of different models vary widely. If all models were billed per call, users of lightweight models would feel that they are subsidizing high-priced models, while heavy users would find that the same task costs vastly different amounts on different models. The multiplier system works by first defining a unified metering unit and then setting a multiplier coefficient for each model.

    The calculation is as follows:

    • Raw metering value: converted from token count. For example, 1 metering point equals 1,000 tokens (input and output combined); the exact conversion ratio is defined and published by the platform.
    • Consumed quota = raw metering value × model multiplier.

    The multiplier uses a baseline model as 1.0. The lower the multiplier, the less quota the same task consumes. This design has three benefits:

    1. Predictable: Users can see the multiplier on the model selection page and estimate cost before choosing a model.
    2. Comparable: The multiplier places the costs of different models on the same scale, making cost-effectiveness easier to compare.
    3. Governable: When the platform adjusts the multiplier of a model, it does not need to change the entire billing framework.

    The following table is an example multiplier table. It is used only to illustrate the structure and does not represent the pricing of any real product.

    Model Multiplier Suitable tasks Whether free quota covers everyday lightweight tasks
    Lite (in-house lightweight version) 0.5 Short-text rewriting, Q&A, key-point organization Yes
    Pro (in-house professional version) 2.0 Multi-step reasoning, long-form analysis Partially covered
    External cost-effective model A 0.8 Summarization, medium-length writing Partially covered
    External long-context model B 3.0 Very long document reading, cross-file analysis Usually not covered

    The order in which free quota is deducted determines whether users find billing reasonable. In the example below, free_remaining is the user’s remaining free quota in the current cycle, in metering points. discount_factor looks up the discount period and model and returns a coefficient between 0 and 1, or 1.0 when there is no discount.

    1. from datetime import datetime
    2. def settle(tokens_used: int, model_id: str, free_remaining: float, now: datetime) -> tuple[float, float]:
    3. """Return (billable metering points, remaining free quota after deduction)."""
    4. raw_units = tokens_used / 1000 # Raw metering value
    5. consumed = raw_units * MULTIPLIER[model_id] # Consumed quota
    6. # Step 1: Deduct from free quota first
    7. from_free = min(consumed, max(free_remaining, 0.0))
    8. overflow = consumed - from_free # Amount exceeding free quota
    9. # Step 2: Apply the discount factor only to the overflow
    10. bill = overflow * discount_factor(now, model_id)
    11. return bill, free_remaining - from_free

    The key point of this logic is that free quota is deducted first, and only the overflow is billed. It is neither “bill the full amount once free quota is exceeded” nor “free for the entire order.” Suppose a task consumes 3 metering points and the user has 2 metering points of free quota remaining. Then 2 metering points are covered by free quota, and only 1 metering point needs to be billed.

    3. Free Quota and Time-Based Discounts

    Cost governance for multi-model platforms…