Cap usage with credits
Price each AI tool in credits, and every call spends from the person's balance. When the balance runs out, the next call is refused until they top up. You build and store no per-person counter. Gemmein keeps the per-minute count itself (section 04).
const { balance, reserved, expiring } = await g.credits.balance();
// A tool call is refused when the balance cannot cover its price:
// "Deep Research costs 20 credits. You have 7."Give each person a budget
Top people up each subscription period, sell packs for pay-as-you-go, or grant credits by hand. Mixing them gives each paid tier its own budget, with packs for more.
Credits by hand
Grant credits to one person from the dashboard or through a relay, for a trial or a goodwill top-up. Their spending stays capped at what you grant.
Paid tiers
A subscription tops the person up each cycle, and packs add more on demand. Packs never expire, so unused credits carry over unless you design otherwise.
Limit which people can run a tool
Credits limit how much a person can run. Access limits which tools they can run. Require access on a tool, and only people who have it can run the tool, whatever their balance. That keeps an expensive model behind a paid plan while a cheaper one stays open to everyone.
Built-in abuse limits
Separately from your pricing, each person can make up to 20 AI calls a minute. The next call is refused with 429 ai_capped and a resetAt time. App-wide safe limits sit above that. They scale with the app's active people, are never billed, and start high enough that a small app is never refused. You don't configure any of them.
Prompt for your coding agent
Paste this into Cursor, Claude, Bolt or Lovable so your agent caps usage with credits and writes no counters of its own.
Read https://docs.gemmein.com/llms.txt and https://docs.gemmein.com/ai. I want to rate-limit AI usage per user. Show me how to price an AI tool in credits so each call spends from the person's balance, grant each person a per-plan credit budget, require access on an expensive tool, and read the person's balance. Explain how the built-in safe limits handle abuse.
npx gemmein devRead the getting-started guide