What is the reserve / commit / release pattern?
reserve atomically holds quota with a 60-second TTL; commit confirms the reservation after the AI call succeeds; release rolls it back on failure. Reservations auto-release on crash. The only correct way to enforce AI quotas under concurrency.
Last updated: 2026-05-10
Why it exists
The naive flow - canUse → call OpenAI → track - has a race window. Two parallel requests can both pass canUse before either has tracked. Reserve / commit / release closes that race by making the check-and-increment atomic.
Lifecycle
reserve(): the slot is yours for 60 seconds. commit(): confirm - counter stays incremented. release(): roll back - counter decrements. No call: auto-releases after 60 seconds.
Why 60 seconds
Long enough for almost every AI call (LLMs, images, agent loops). Short enough that crashed workers don't leak quota for long.
Related questions
How do I track LLM usage per user?
Call vevee.track(userId, "llm.tokens", tokenCount) after each LLM call. AIPricingLab counts it against the user's plan limits in real time a…
Q&AHow do I rate-limit OpenAI calls per user?
Use vevee.reserve(userId, "openai.chat", 1) before the OpenAI call. If allowed=false, return 429. If allowed=true, call OpenAI then commit o…