How Credits Work
Understand how Proma credits flow from users to developers.
Credits are the core of Proma's billing system. Instead of each app running its own payment infrastructure, Proma provides a single credit balance that users spend across the entire marketplace.
The Credit Lifecycle
1. Users Buy Credits
Users purchase credits directly on Proma. They choose a top-up amount, pay once, and their balance is available immediately. No subscriptions, no recurring charges.
2. Users Spend Credits in Your App
When a user performs an action in your app — generating AI content, processing data, or using a premium feature — your app calls the Credits API to deduct from their balance.
await proma.credits.spend({
amount: 10,
description: 'Generated blog post outline',
});
3. Proma Tracks Everything
Every credit transaction is recorded with the app ID, user ID, amount, and description. Users can see exactly where their credits went in their Proma dashboard.
4. Developers Earn Revenue
Proma settles with developers based on the credits spent in their apps. You earn a share of every credit your app consumes.
Checking Balances
Before performing an expensive action, check if the user has enough credits:
const { balance } = await proma.credits.getBalance();
if (balance < requiredAmount) {
// Prompt user to top up on Proma
window.open('https://proma.dev/home/credits', '_blank');
return;
}
AI Gateway Credits
When you use Proma's AI gateway, credits are deducted automatically based on token usage. You don't need to call credits.spend() — the gateway handles billing:
// Credits are deducted automatically per token
const stream = proma.ai.chat({
messages: [{ role: 'user', content: 'Write a haiku about coding' }],
});
Token costs:
- Input tokens: 1 micro-credit each
- Output tokens: 2 micro-credits each
Best Practices
- Check balance before expensive operations — don't let users start a task they can't finish
- Use descriptive labels — help users understand what they're paying for in their transaction history
- Handle insufficient balance gracefully — guide users to top up rather than showing an error
- Batch small operations — if your app makes many small deductions, consider batching them into a single spend call