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.
from dataclasses import dataclass, fieldfrom datetime import date@dataclassclass TierQuota:tier: strdaily_token_limit: int # Model tokens allowed per day@dataclassclass UsageRecord:used_tokens: int = 0day: date = field(default_factory=date.today)class QuotaManager:def __init__(self, quotas: dict[str, TierQuota]):self._quotas = quotasself._usage: dict[str, UsageRecord] = {}def _get_record(self, user_id: str) -> UsageRecord:record = self._usage.get(user_id)if record is None or record.day != date.today():record = UsageRecord()self._usage[user_id] = recordreturn recorddef check_and_charge(self, user_id: str, tier: str, tokens: int) -> bool:quota = self._quotas[tier]record = self._get_record(user_id)if record.used_tokens + tokens > quota.daily_token_limit:return Falserecord.used_tokens += tokensreturn Truequotas = {"free": TierQuota("free", daily_token_limit=50_000),"enterprise": TierQuota("enterprise", daily_token_limit=10_000_000),}manager = QuotaManager(quotas)if not manager.check_and_charge("user-001", "free", tokens=1_200):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.
import threadingimport timeclass TokenBucket:def __init__(self, rate: float, capacity: float):self.rate = rate # Permits added per secondself.capacity = capacity # Bucket capacity, which sets the maximum allowed burstself._permits = capacityself._updated_at = time.monotonic()self._lock = threading.Lock()def acquire(self, amount: float = 1.0) -> bool:with self._lock:now = time.monotonic()elapsed = now - self._updated_atself._permits = min(self.capacity, self._permits + elapsed * self.rate)self._updated_at = nowif self._permits >= amount:self._permits -= amountreturn Truereturn False# Free tier: 2 requests per second on average, with bursts of up to 10free_limiter = TokenBucket(rate=2.0, capacity=10.0)# Enterprise tier: 50 requests per second on average, with bursts of up to 200enterprise_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.
import heapqimport itertoolsimport timePRIORITY = {"enterprise": 0, "free": 1}_sequence = itertools.count()class RequestScheduler:def __init__(self, aging_seconds: float = 30.0):self._heap: list[tuple[float, int, dict]] = []self._aging_seconds = aging_secondsdef _effective_priority(self, tier: str, submitted_at: float) -> float:base = PRIORITY[tier]waited = time.monotonic() - submitted_at# Each aging period raises the effective priority by one level,# so low-priority requests do not starvereturn base - waited / self._aging_secondsdef submit(self, tier: str, payload: dict) -> None:submitted_at = time.monotonic()priority = self._effective_priority(tier, submitted_at)heapq.heappush(self._heap, (priority, next(_sequence), payload))def next_request(self) -> dict | None:if not self._heap:return None_, _, payload = heapq.heappop(self._heap)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
