Large Model Commercialization: Shifting from Custom Deployment to Usage-Based API Serving

    This article compares private or custom deployment of large models with usage-based, token-billed service delivery. It covers how the two models differ in engineering focus, what drives inference cost (batching, quantization, context length, and prefix caching), how multi-tenant metering and idempotent billing work, how token-based rate limiting and observability support stability, and how teams can phase a migration to service-based delivery.

    1. The Core Difference Between the Two Delivery Models

    Large model capabilities are usually delivered in one of two ways. The first is private or custom deployment. The customer provides or purchases the compute resources, and the model runs in an environment the customer specifies. The vendor charges per project, and fees typically cover requirements research, data adaptation, deployment, and ongoing operations. The second is service-based delivery. The model runs in the vendor’s inference cluster, customers send requests over a network interface, and billing is based on the number of input and output tokens.

    The two models put engineering effort in different places. Custom projects focus on delivery timelines and environment adaptation, and the profit on each project depends on whether labor input can be kept under control. Service-based delivery focuses on unit inference cost, concurrency capacity, and metering accuracy. As the number of projects grows, the marginal cost of a service-based model does not rise linearly, but it places greater demands on the scalability and stability of the infrastructure.

    Understanding this difference is the starting point for architecture decisions. If the business relies mainly on one-time deliveries, the project-based process is simpler. If demand comes from many similar customers, standardizing the capability and offering it as a service usually scales better.

    2. Why Service-Based Delivery Has Become the Mainstream Direction

    Revenue from project-based work is capped by the size of the delivery team. Each new customer requires another round of environment preparation, model adaptation, and acceptance testing. A service model wraps model capabilities in a unified interface. The same inference resources can serve many customers at once, and revenue grows with call volume without a matching increase in delivery staff.

    This shift also changes the gross margin structure. Let C be the inference cost of a single call and P be the fee charged for that call. The unit gross margin can be approximated as (P − C) / P. As inference cost keeps falling through batching, quantization, caching, and scheduling optimization, gross margin improves at larger scale.

    The same model can produce very different gross margins depending on the product form. For subscription products aimed at individual users, usage is hard to predict, and heavy users may cost more to serve than their subscription fee. Products billed per call tie cost to revenue. Each call has a price, so the cost structure is easier to estimate. The choice of product form therefore directly affects pricing strategy and the financial model.

    3. Inference Cost Components and Optimization Paths

    Unit token cost is mainly determined by the following factors:

    • Model size and memory footprint: A larger parameter count means each accelerator card can hold fewer concurrent requests, so the hardware cost per token rises.
    • Batching efficiency: Dynamic batching improves accelerator utilization, but it increases queuing time for individual requests and raises time to first token. Teams need to trade off throughput against latency.
    • Context length: Longer inputs increase attention computation and KV cache usage. Long-document workloads usually cost noticeably more than short conversations.
    • Quantization and inference engine: Low-precision weights and efficient kernels reduce the computation per unit, but they may cause accuracy loss, which must be verified with an evaluation set.
    • Prefix caching: Repeated system prompts, templates, or document prefixes can reuse intermediate computation results, which reduces redundant computation.

    The effect of each optimization depends on the specific model and workload. Teams should run load tests with their own real traffic, record throughput, latency, and memory usage, and calculate unit cost from those measurements. Data from other scenarios should not be applied directly.

    4. Multi-Tenant Metering and Billing Design

    A service-based platform has to solve three problems: accurate metering, tenant isolation, and traceable settlement.

    Metering is best done at the gateway layer or at the exit of the inference service. Record each request’s tenant ID, model name, input and output token counts, timestamp, and request ID. Store billing data separately from runtime logs, so that log sampling or client retries cannot cause duplicate or missed charges. The request ID is used for idempotent deduplication. If the same request is resent, it is billed only once.

    The following simplified metering example shows the record structure and the basic logic for summing usage by tenant. The unit prices are illustrative. Actual pricing should be set based on cost and market conditions.

    1. from collections import defaultdict
    2. from dataclasses import dataclass
    3. @dataclass(frozen=True)
    4. class UsageRecord:
    5. request_id: str
    6. tenant_id: str
    7. model: str
    8. input_tokens: int
    9. output_tokens: int
    10. # Illustrative unit prices, in CNY per 1K tokens
    11. PRICE_PER_K = {"input": 0.002, "output": 0.004}
    12. class Meter:
    13. def __init__(self):
    14. self._seen = set() # Processed request IDs, used for idempotent deduplication
    15. self._usage = defaultdict(float) # Tenant -> amount receivable
    16. def record(self, rec: UsageRecord) -> bool:
    17. if rec.request_id in self._seen:
    18. return False # Duplicate report, ignore it
    19. self._seen.add(rec.request_id)
    20. cost = (rec.input_tokens * PRICE_PER_K["input"]
    21. + rec.output_tokens * PRICE_PER_K["output"]) / 1000
    22. self._usage[rec.tenant_id] += cost
    23. return True
    24. def bill(self, tenant_id: str) -> float:
    25. return round(self._usage[tenant_id], 4)

    A production system also needs persistence, deduplication storage shared across nodes, reconciliation, and handling for abnormal requests. The in-memory set in this example cannot be shared across multiple instances, so production environments should use reliable distributed storage for deduplication.

    5. Traffic Governance and Stability Assurance

    In a multi-tenant environment, a traffic burst from one customer can crowd out resources for others. Traffic governance usually includes rate limiting, queuing, degradation, and circuit breaking.

    Limiting by request count is not reasonable. One request might contain only a few dozen tokens, while another contains a long document with tens of thousands of tokens. The resources they consume differ greatly. A better approach is to limit by token count, or to set quotas on both request count and token count.

    The token bucket example below performs admission control based on estimated token cost. To avoid confusion with model tokens, the code calls this quantity a “budget.”

    1. import threading
    2. import time
    3. class BudgetBucket:
    4. def __init__(self, refill_per_sec: float, capacity: float):
    5. self.refill_per_sec = refill_per_sec # Budget refilled per second (in thousands of tokens)
    6. self.capacity = capacity # Maximum budget
    7. self.level = capacity
    8. self.last = time.monotonic()
    9. self.lock = threading.Lock()
    10. def try_consume(self, cost: float) -> bool:
    11. with self.lock:
    12. now = time.monotonic()
    13. self.level = min(self.capacity,
    14. self.level + (now - self.last) * self.refill_per_sec)
    15. self.last = now
    16. if self.level >= cost:
    17. self.level -= cost
    18. return True
    19. return False # Over budget: return a rate-limit response or enter a queue

    In addition to rate limiting, set a maximum output length for long requests, add a cancellation mechanism for timed-out requests, and give priority to high-priority tenants when the inference service is overloaded. Degradation strategies can include switching to a smaller model or shortening the maximum output length. The specific choice should be confirmed with the business side.

    6. Observability and Cost Dashboards

    A service-based platform needs continuous monitoring of the following metrics:

    • Time to first token (TTFT): Reflects the response speed users perceive. It is affected by queuing time and prefill computation.
    • Time per output token (TPOT): Reflects how smoothly streaming output is delivered. It is affected by batch size and memory bandwidth.
    • Token consumption per tenant: Used for cost accounting, anomaly detection, and capacity planning.
    • Error rate and timeout rate: Separate errors caused by customer input from errors caused by server-side failures.
    • Queue wait time: A sustained rise in queue time usually signals insufficient capacity.

    A cost dashboard should link token consumption to resource costs, broken down by model, tenant, and time period. This makes unusual calling patterns easier to spot, such as a sudden increase in one tenant’s input length or an abnormally high retry rate on an endpoint.

    7. Practical Steps for Migrating from Custom Delivery to Service-Based Delivery

    Migration is usually not a one-time switch. A phased approach works better:

    1. Separate the deliverables: Keep reusable inference capabilities apart from project-specific adaptation work. The reusable part moves into a standard service, and the project-specific part stays a separate implementation project.
    2. Standardize metering before discussing pricing: Define the token counting rules, whether retries and failed requests are billed, and how usage converts across different models. Make sure invoices can be audited.
    3. Estimate costs from real workloads: Use load tests to measure throughput and latency at different batch sizes, calculate unit cost from those results, and then set a price range.
    4. Run a small pilot: Open the service first to internal users or a small group of customers. Observe rate limiting, billing, and stability before expanding.
    5. Keep a private deployment option: Customers with strict data compliance requirements still need private or dedicated deployment. A service model cannot fully replace it.

    When choosing a hosting platform, compare options on data compliance requirements, latency targets, unit cost, operational capability, and elastic scaling needs. If the platform already provides general capabilities such as metering, rate limiting, and monitoring, the team can reduce its in-house development work. The team still needs to verify that these capabilities meet its own billing rules and isolation requirements.