Priced per call
The price is spent before the call and refunded in full if the provider fails before it answers. A call that dies mid-stream, or one the caller abandons after the first byte, is not refunded.
Price a named AI tool on the server. Gemmein reserves the credits before the call, runs it on your provider key, and settles at what the provider actually used. If the provider fails before it answers, the credits are refunded. The browser never sees the price, the model, or the prompt.
A credit is the unit your customer spends on one AI call. You define the operation once as a named tool and give it a price. From then on, every call to that tool spends that many credits, recorded on the customer's ledger. You never write the metering, and the price is not something the browser can change.
A tool is a file in your project. You write the implementation: provider, model, instructions, template, and inputs. You set its commerce, the price and access gate, in the dashboard. Credits run from 1 to 10,000 per tool.
{
"label": "Deep Research",
"provider": "openai",
"model": "gpt-4o",
"credits": 20,
"requires": "access:pro-max",
"instructions": "You are a careful research assistant. Answer with sources.",
"promptTemplate": "Research this question for a {{audience}} reader:\n\n{{question}}",
"inputs": [
{ "name": "question", "type": "text", "required": true, "maxLength": 2000 },
{ "name": "audience", "type": "text" }
],
"bounds": { "maxOutputTokens": 4000 }
}Carry it with npx gemmein sync (--live into production, with a sync key). The file owns the implementation. The dashboard owns the commerce: credits, requires, and whether the tool is enabled.
Your app calls the tool by name. Gemmein reserves the price, runs the request on your provider key with the pinned model, and settles the charge when the answer ends.
// A name and inputs. The server composes the rest.
const answer = await g.ai.runText("deep-research", {
question: "How can I improve client onboarding?",
audience: "beginner"
});
// The customer's own balance, in the browser, when signed in.
const { balance, reserved, expiring } = await g.credits.balance();The price is spent before the call and refunded in full if the provider fails before it answers. A call that dies mid-stream, or one the caller abandons after the first byte, is not refunded.
A ceiling is reserved before the call, covering the request size plus the output cap. The charge settles at the provider's reported usage, up to that ceiling, when the stream ends cleanly.
Customers buy more credits with a pack. The credits are granted when the signed payment webhook arrives, not when the browser returns from checkout.
Building with Cursor, Claude, Bolt, or Lovable? Paste this so your agent works against the real contract instead of guessing.
Read https://docs.gemmein.com/llms.txt and https://docs.gemmein.com/ai. I want to charge credits for an AI feature. Show me how to define a priced AI tool on the server (a tool file with provider, model, instructions and inputs), set its credit price and access gate, and call it by name from my app. Explain how credits are reserved and settled, and how a customer buys more credits so the grant lands on the signed payment webhook, not the checkout redirect.
npx gemmein devRead the getting-started guide A per-call price is spent before the call and refunded if the provider fails before answering. A per-token price reserves a ceiling before the call and settles at the provider's reported usage, up to that ceiling, when the answer ends cleanly. A stream that does not end cleanly, or a call abandoned mid-answer, costs the ceiling.
Credits sit on a grant, such as a credit pack. Credit packs never expire.
No. The price, the model, and the access gate live on the server. The app sends a tool name and inputs. It never sends a price, a model, or a prompt. Raw provider calls from the browser are off by default.
They buy a pack. The grant is added when the signed payment webhook arrives, not on the checkout redirect. A redirect can be faked; the webhook cannot.
Yes. Spend credits from your own server for anything you want to meter that is not an AI tool call.
AI tools and credits on the product page · Where your OpenAI key should live · Gemmein vs Supabase for AI apps · AI docs
Point your coding agent at docs.gemmein.com/llms.txt and ask it to confirm the fit before it builds.