# Charge for AI usage before it charges you.

> Sell credit packs, set usage limits per plan and top up when a balance runs low, on your own Stripe account, so every AI request is paid for.

Page: https://www.buildbase.app/use-cases/ai-credits

Sell credit packs, set limits per plan and top up automatically when a balance runs low. Your users always see what they have left.

**What it is:** BuildBase is one SDK and console for React apps with credits, usage limits, billing and sign-in built in.

Set up credits: https://console.buildbase.app

For your coding agent: Add BuildBase credits to this app: credit packs, a balance users can see, and a limit per plan on the AI feature. Start with: npx skills add buildbase-app/claude-skill

## How a request gets paid for

The same path every time a user runs your AI feature.

1. **Check.** Your server asks BuildBase whether the workspace has the credits or quota for this request.
2. **Run.** The AI call runs only after the check passes, so nobody gets a free request.
3. **Deduct.** Credits are consumed and the user's balance updates at once.
4. **Top up.** When a balance runs low, a workflow can warn the user, or auto top-up buys the next pack.

## What AI features cost when nobody meters them

Every request costs you money. Without credits or limits, your best users are also your most expensive ones.

| Without it | Already covered |
| --- | --- |
| A way to sell usage, not only a monthly plan | Credit packs bought through your own Stripe |
| A limit on what Free users can run | Usage limits per plan, checked before the request runs |
| A balance users can see and trust | Balances that update the moment credits are used |
| A top-up before users hit zero | Auto top-up buys the next pack when a balance runs low |
| Promotional credits without a spreadsheet | Grants that expire on a schedule |

## Usage billing for AI, already built

- **Credit packs.** Sell packs on your own Stripe, so heavy users buy more instead of costing you more. (Credits & Usage Metering: https://www.buildbase.app/credits)
- **Limits per plan.** Set how much each plan may use, so your free plan stays affordable to run. (Billing & Subscriptions: https://www.buildbase.app/billing)
- **A balance users can see.** Balances update as credits are consumed, so users always know what they have left. (Credits & Usage Metering: https://www.buildbase.app/credits)
- **Auto top-up.** The next pack is bought when a balance runs low, so work does not stop halfway. (Credits & Usage Metering: https://www.buildbase.app/credits)
- **Grants that expire.** Give promotional credits on a schedule, so a launch offer costs what you planned. (Credits & Usage Metering: https://www.buildbase.app/credits)
- **Overage on Stripe meters.** Usage past an allowance can be reported to Stripe Billing Meters, so a big month bills correctly. (Billing & Subscriptions: https://www.buildbase.app/billing)

## Building credits yourself

Credit packs, plan limits, top-ups and payment events, built with an AI coding agent and kept running, against setting them up here.

|  | Build it yourself | BuildBase |
| --- | --- | --- |
| Hours | 75 | 7 |
| Time | about 2.5 weeks | about 1.2 days |
| First year | $7,905 | $610 (Launch, paid yearly) |

Modules: Credits & Usage Metering, Billing & Subscriptions, Webhooks & Events. At $60 an hour. Estimates for a senior developer working with an AI coding agent such as Claude Code or Cursor, tests included. Upkeep covers dependency upgrades, provider API changes, incidents and support. Not a quote. Last reviewed 17 November 2026. Calculator: https://www.buildbase.app/build-vs-buy

## Credits in three steps

1. **Create your packs.** In the console, define your credit packs, the limit each plan includes and when to top up.

In the console (Console: Credits):

| Setting | Value |
| --- | --- |
| Credit pack | Starter pack |
| Plan limit | ai-generations, monthly |
| Auto top-up | On when low |
| Grant | Launch offer, expires |

2. **Check before you spend.** On your server, before each AI request, check the quota and consume the credits it uses.

```tsx
import BuildBase from '@buildbase/sdk';

const bb = BuildBase({ serverUrl, orgId, getSessionId });

// Record usage and check quota
const usage = await bb.usage.record(workspaceId, {
  quotaSlug: 'api-calls',
  quantity: 1,
});

if (usage.available <= 0) {
  return Response.json(
    { error: 'Quota exceeded' },
    { status: 429 }
  );
}

// Consume credits
const result = await bb.credits.consume(
  workspaceId,
  { amount: 10, description: 'AI generation' }
);
```

3. **Show the balance.** Show what is left, and a prompt to buy more when it runs low, from the same SDK.

```tsx
import {
  useCreditBalance,
  useConsumeCredits,
  useExpiringCredits,
  WhenCreditsExhausted,
  WhenCreditsLow,
} from '@buildbase/sdk/react';

function AIFeature({ workspaceId }) {
  const { balance } = useCreditBalance(workspaceId);
  const { consumeCredits } = useConsumeCredits(workspaceId);
  const { expiringCredits } = useExpiringCredits(workspaceId, 7);

  const handleGenerate = async () => {
    try {
      await consumeCredits({ amount: 10, description: 'AI generation' });
      // proceed with generation
    } catch (err) {
      if (err.code === 'INSUFFICIENT_CREDITS') {
        // err.available and err.requested are available
      }
    }
  };

  return (
    <>
      <p>Credits: {balance?.available}</p>
      {expiringCredits > 0 && <p>{expiringCredits} credits expire soon</p>}

      <WhenCreditsLow threshold={10}>
        <p>Running low — buy more credits.</p>
      </WhenCreditsLow>

      <WhenCreditsExhausted>
        <p>No credits left.</p>
      </WhenCreditsExhausted>

      <button onClick={handleGenerate}>Generate (10 credits)</button>
    </>
  );
}
```


## Running in production

Running in production on six products today, all of them ours.

- [OnceBooks](https://www.oncebooks.com): Personalised children's books
- [PlugNode](https://plugnode.ai): Visual AI workflow builder
- [AgentCenter](https://www.agentcenter.cloud): Mission control for AI agents
- [Imejis](https://www.imejis.io): Template-based image generation API
- [RemoteWait](https://remotewait.com): Virtual queue system
- [LinkTracer](https://social-link-tracer.jagodana.com): Creator link analytics

## No fee on your credit sales

Your users' payments go to your own Stripe with a 0% platform fee. BuildBase starts at $0, and Launch is $19 a month.

| Plan | Monthly | Yearly | Monthly active users | Workspaces |
| --- | --- | --- | --- | --- |
| Free | $0 | $0 | 10,000 | 50 |
| Launch | $19 | $190 | 25,000 | 1,000 |
| Grow | $49 | $490 | 100,000 | 25,000 |
| Scale | $99 | $990 | 500,000 | 100,000 |

Paid plans start with a 7-day free trial, no credit card. Free stops at its allowance and never bills over. Enterprise: Custom, by conversation. Full pricing: https://www.buildbase.app/pricing

## Questions

### Is this a full usage-metering platform?

No. Credits and quotas are built for an app's own pricing: packs, limits per plan, grants, top-ups and overage on Stripe Billing Meters. If you need event-time metering with corrections or aggregations other than a sum, a dedicated metering tool fits better.

### Can I mix a subscription with credits?

Yes. Plans carry their own limits, and users can buy credit packs on top of their subscription.

### Do you take a fee on credit sales?

No. Payments through your own Stripe account carry a 0% platform fee. Stripe's own fees apply as usual.

### What happens when a user runs out?

The check fails before the request runs, so you never pay for a request nobody paid for. Your app shows a prompt to buy more, or auto top-up buys the next pack before the balance reaches zero.

### What does BuildBase itself cost?

The Free plan is $0 and stops at its allowance instead of billing you. Paid plans start at $19 a month with a 7-day trial and no card.


## Read more

- [What is usage-based billing?](https://www.buildbase.app/blog/what-is-usage-based-billing)
- [Metered vs seat-based billing](https://www.buildbase.app/blog/metered-vs-seat-based-billing)
- [Credits and usage limits for an AI app you built with a prompt](https://www.buildbase.app/guides/credits-and-usage-limits-for-an-ai-app)
- [The credits module](https://www.buildbase.app/credits)
- [Charge for your app](https://www.buildbase.app/use-cases/charge-for-your-app)
- [MCP server for your app](https://www.buildbase.app/use-cases/mcp-server-for-your-app)
- [Trial and payment emails](https://www.buildbase.app/use-cases/trial-conversion-emails)
- [All use cases](https://www.buildbase.app/use-cases)
