AI Token Pricing with Limitr
Enforcing usage-based limits for AI products, built on Limitr.
AI products charge per API call, token, or compute unit. Problems with limits.ts:
Hard-coded thresholds that need constant redeploys
Special cases for paid/free users, free tiers, or trial periods
Complexity when multiple models, token types, or rate-limits exist
No easy audit for usage overages
Hard to integrate with billing or monitoring
AI token pricing is dynamic. Limits and usage tracking must evolve without touching the app code.
How Limitr Solves It
Limitr separates usage policy from application logic.
Define credits for tokens
Attach entitlements to plans
Track meters per customer
Enforce limits at runtime
Emit events when limits are reached
Benefits:
Update token limits instantly without redeploying
Keep usage state explicit and auditable
Integrate easily with billing systems
Handle overages with soft or hard enforcement
Example: Token-Based Limits
Free users have a soft limit of 1,000 tokens per month (overage triggers events, but may be allowed)
Pro users have a hard limit of 10,000 tokens per month
Enforcing Token Usage
policy.allowautomatically updates the meter if a hard limit hasn't been reachedEvents (
meter-limit,meter-overage, etc.) fire on threshold violationsThe app decides how to respond (block, warn, bill, or notify)
Metering Multiple Models
Many AI products have multiple models with different token costs:
Each entitlement tracks a specific model or token type
Meters are stored per customer
Overages emit events per entitlement, giving granular insight
Soft vs Hard Limits
Soft Limit: Usage above the limit triggers events but may be allowed
Hard Limit: Usage above the limit is blocked automatically
This allows AI products to warn users or record overages before enforcing strict caps.
Why Limitr Beats limits.ts for AI
limits.ts for AIProblem
limits.ts
Limitr
Frequent token limit changes
Requires redeploy
Update policy without redeploy
Multiple models / token types
Requires branching
Each entitlement is explicit
Auditing usage
Hard to track
Meters are inspectable & auditable
Event-driven overages
Must write custom logic
Built-in event system
Integration with billing
Custom code
Subscribe to events, no coupling
Getting Started
Define your credits for tokens and entitlements for each plan
Attach customers (users/orgs/api keys) to plans
Increment meters as API calls happen
Listen for events to handle overages or billing
Limitr lets you start simple (free vs pro) and scale up to complex AI pricing without touching your application code.
Last updated
Was this helpful?