Designing Free and Enterprise Tiers for AI Service APIs

    This article explains how to design free and enterprise tiers for large language model services that serve both individual users and business customers. It compares the needs of the two groups and covers three principles: resource isolation, usage metering, and graceful degradation under overload. It includes Python examples for quota management, token bucket rate limiting, priority scheduling with aging, and multi-tenant isolation, followed by product metrics and a launch checklist.

    1. The Starting Point: Where Should the Free Tier Draw the Line?

    When a large language model service serves both individual users and enterprise customers, operators soon face a question: should the free tier stay open, and if so, how far should it go? Online discussions often frame this as “free users will be abandoned.” That framing reduces the problem to a clash of positions. From a technical and resource planning perspective, three questions are more useful: how much compute each inference consumes, who bears those costs, and how service quality is distributed among user groups.

    Inference cost depends directly on input and output length, model size, and concurrency. A large number of free users and uneven request distribution can cause peak traffic to crowd out paying or enterprise users. Without a tiering mechanism, a burst of load from any one user group can slow overall latency and even cause some requests to fail.

    Therefore, the core of tiered design is not deciding whether to offer a free tier. It is setting clear rules for resource contention, and making sure those rules can be enforced, observed, and adjusted.

    2. Differences Between the Two User Groups

    General users and enterprise users differ clearly in how they use the service, so the tiers need to be designed for each group separately.

    Dimension General users Enterprise users
    Core needs Free, easy to use, ready to use immediately Stable and predictable latency and availability
    Call pattern Interactive, low frequency, highly bursty Programmatic calls, high frequency, batch processing
    Price sensitivity High More focused on total cost and contract terms
    Service level requirements Usually lower, and queuing is acceptable Clear availability and response time targets
    Data and compliance Concerned with personal data protection Concerned with data isolation, auditing, and deployment methods

    These differences mean that if one resource pool serves both groups without distinction, the stability needs of enterprise users will be disrupted by bursts of free traffic. At the same time, an unconstrained free tier is hard to sustain. The goal of tiering is to draw a clear boundary between the two.

    3. Three Principles of Tiered Design

    3.1 Resources Can Be Isolated

    Different tiers should use separate queues or quota pools. Isolation can start at the logical level, for example by assigning quotas and priorities per tier. When enterprises require higher stability, the design can move to dedicated resource pools or even dedicated deployments. Isolation does not have to be complete from the start, but every tier should have clear resource boundaries.

    3.2 Usage Can Be Metered

    Metering units need to be consistent. For large model services, a common approach is to measure usage in input and output tokens, and to record the time, user, tier, and consumption of each request. Consistent metering is the basis for quota control, and it also supports later cost analysis and billing. Metering data should be traceable so that disputes can be investigated.

    3.3 Overload Can Be Degraded Gracefully

    When resources are tight, the system should handle requests according to a predefined policy. Typical policies include lowering the concurrency limit for the free tier, shortening queue wait times for free requests, and returning clear error messages for requests that exceed quota. The key is that degradation is predictable. The system should not slow every request at once or fail requests at random.

    4. Technical Implementation

    The examples below show several basic components of tiered control. They assume a single process to illustrate the approach. A production environment would need to replace them with shared storage and distributed locking.

    4.1 Quota Management by Usage

    Quota management determines whether a user still has remaining quota in the current period. The code below resets usage daily and checks the limit before deducting.

    1. from dataclasses import dataclass, field
    2. from datetime import date
    3. @dataclass
    4. class TierQuota:
    5. tier: str
    6. daily_token_limit: int # Model tokens allowed per day
    7. @dataclass
    8. class UsageRecord:
    9. used_tokens: int = 0
    10. day: date = field(default_factory=date.today)
    11. class QuotaManager:
    12. def __init__(self, quotas: dict[str, TierQuota]):
    13. self._quotas = quotas
    14. self._usage: dict[str, UsageRecord] = {}
    15. def _get_record(self, user_id: str) -> UsageRecord:
    16. record = self._usage.get(user_id)
    17. if record is None or record.day != date.today():
    18. record = UsageRecord()
    19. self._usage[user_id] = record
    20. return record
    21. def check_and_charge(self, user_id: str, tier: str, tokens: int) -> bool:
    22. quota = self._quotas[tier]
    23. record = self._get_record(user_id)
    24. if record.used_tokens + tokens > quota.daily_token_limit:
    25. return False
    26. record.used_tokens += tokens
    27. return True
    28. quotas = {
    29. "free": TierQuota("free", daily_token_limit=50_000),
    30. "enterprise": TierQuota("enterprise", daily_token_limit=10_000_000),
    31. }
    32. manager = QuotaManager(quotas)
    33. if not manager.check_and_charge("user-001", "free", tokens=1_200):
    34. print("Today's free quota has been used up. Please try again tomorrow or upgrade your plan.")

    In a real system, two points need attention. First, the check-then-deduct logic in check_and_charge is not atomic in multithreaded or multiprocess scenarios, which can lead to over-deduction. The fix is to use shared storage with atomic operations, or to lock this method. Second, the estimated token count often differs from the actual consumption. A common approach is to reserve quota based on the estimate first, then settle using the actual value after the request finishes.

    4.2 Token Bucket Rate Limiting

    Quota control limits total volume, while rate limiting controls speed. The token bucket algorithm allows some bursty requests while capping the long-term average rate. This makes it suitable for controlling the request frequency of an API.

    Note that a “token” here means a permit in the rate-limiting algorithm. It is a different concept from the tokens used in large language models. The implementation below uses a lock to ensure thread safety.

    1. import threading
    2. import time
    3. class TokenBucket:
    4. def __init__(self, rate: float, capacity: float):
    5. self.rate = rate # Permits added per second
    6. self.capacity = capacity # Bucket capacity, which sets the maximum allowed burst
    7. self._permits = capacity
    8. self._updated_at = time.monotonic()
    9. self._lock = threading.Lock()
    10. def acquire(self, amount: float = 1.0) -> bool:
    11. with self._lock:
    12. now = time.monotonic()
    13. elapsed = now - self._updated_at
    14. self._permits = min(self.capacity, self._permits + elapsed * self.rate)
    15. self._updated_at = now
    16. if self._permits >= amount:
    17. self._permits -= amount
    18. return True
    19. return False
    20. # Free tier: 2 requests per second on average, with bursts of up to 10
    21. free_limiter = TokenBucket(rate=2.0, capacity=10.0)
    22. # Enterprise tier: 50 requests per second on average, with bursts of up to 200
    23. enterprise_limiter = TokenBucket(rate=50.0, capacity=200.0)

    The two parameters of a token bucket map to two kinds of user experience. The refill rate determines long-term average throughput, and the bucket capacity determines whether short bursts are accepted. Both should be set based on the actual call pattern of the business, not fixed by rule of thumb.

    4.3 Priority Scheduling and Starvation Prevention

    When requests enter a queue, the scheduler needs to decide which one to process first. Priority by tier is the most direct approach. However, strict priority scheduling can starve low-priority requests, which may wait indefinitely. A common remedy is aging: the longer a request waits, the higher its effective priority.

    1. import heapq
    2. import itertools
    3. import time
    4. PRIORITY = {"enterprise": 0, "free": 1}
    5. _sequence = itertools.count()
    6. class RequestScheduler:
    7. def __init__(self, aging_seconds: float = 30.0):
    8. self._heap: list[tuple[float, int, dict]] = []
    9. self._aging_seconds = aging_seconds
    10. def _effective_priority(self, tier: str, submitted_at: float) -> float:
    11. base = PRIORITY[tier]
    12. waited = time.monotonic() - submitted_at
    13. # Each aging period raises the effective priority by one level,
    14. # so low-priority requests do not starve
    15. return base - waited / self._aging_seconds
    16. def submit(self, tier: str, payload: dict) -> None:
    17. submitted_at = time.monotonic()
    18. priority = self._effective_priority(tier, submitted_at)
    19. heapq.heappush(self._heap, (priority, next(_sequence), payload))
    20. def next_request(self) -> dict | None:
    21. if not self._heap:
    22. return None
    23. _, _, payload = heapq.heappop(self._heap)
    24. return payload

    The implementation above calculates priority at enqueue time, which works for a demonstration. A more rigorous approach is to recalculate priority from the current wait time before each dequeue, or to use multi-level queues with periodic adjustment. Whichever method you use, set a queue timeout for the free tier. When the timeout expires, return a clear message instead of waiting indefinitely.

    4.4 Multi-Tenant Isolation

    Multi-tenant isolation can be considered at three levels:

    • Data isolation: The inputs, outputs, and session records of different users are stored independently, and access checks ownership.
    • Resource isolation: Separate queues, concurrency pools, or compute nodes prevent the load of one user group from affecting another.
    • Deployment isolation: For enterprises with highly sensitive data or very high stability requirements, dedicated resources or private deployment options can be offered.

    Higher isolation costs more. When designing a system, choose the isolation level that matches each customer’s compliance requirements and payment level, rather than applying the highest standard to every user.

    5. Product Perspective: Positioning and Boundaries of the Free Tier

    The free tier usually serves three purposes in a product lineup: lowering the barrier to entry, collecting feedback, and building a long-term user base. These purposes have real value, but the free tier also creates cost pressure. Operators need clear answers to several questions. How large is the free quota? Which features are included? Is commercial use allowed? How is the concurrency limit set? How are users notified when rules change?

    Whether the rules are public and predictable directly affects user trust. On the technical side, the following metrics can support decisions:

    • Average resource cost per request, broken down by tier
    • Share of total requests from the free tier, and its occupancy during peak hours
    • Conversion rate and timing from free users to paid or enterprise tiers
    • Average latency, queue time, and error