Usage-based billing and plan limits
Hard ceilings via ECKO_AI_MAX_CALLS and exact decimal math when usage converts to an invoice line.
The problem
Plans include "500 AI actions per month" or overage priced per thousand tokens. Enforcing that in application code means counting calls in Redis, racing on increments, and hoping the billing cron matches what the model provider charged you.
When overage is money, floating-point unit prices are how you accidentally undercharge a enterprise customer by four cents forty thousand times.
Why Ecko
- Process-wide call budget
ECKO_AI_MAX_CALLSstops a runaway handler or batch job from exceeding a configured ceiling - a backstop even when your own counter has a bug.- Decimal overage rates
- Compute
0.002m * decimal(tokens)for an overage line. No cents-lost-to-float when the usage table feeds finance. - Typed usage records
- Emit structs with tenant, period, calls, tokens, and cost straight into your billing export. Validation catches a missing field before Stripe sees it.
In practice
# ECKO_AI_MAX_CALLS=500 per worker invocation overage = decimal(tokens()) * 0.002m
Try it on your workload.