Token metering · Quotas · Credits · Billing

Your AI app is
leaking money. MeterKit stops it.

Drop-in token metering, quotas, prepaid credits and Stripe billing for Next.js AI apps. One withAiGuard wrapper — self-hosted, your data, one-time purchase.

app/api/chat/route.ts
export const POST = withAiGuard(handler, {
  quota:    { tokens: 5_000_000, per: 'month' },
  spendCap: { cents: 5_000 },
  onExceed: 'block',
});

Simulated terminal: two requests succeed and are metered; the third is blocked with 402 quota_exceeded once the monthly cap is reached. Zero overspend.

Simulated output.

  • 381 tests
  • TypeScript strict
  • 3 runtime deps
  • Memory + Postgres
  • One-time purchase

What you get

Everything between your app and the invoice

  • Quotas & spend caps

    Per-user token quotas and hard monthly spend limits. 402, not surprise bills.

  • Prepaid credits

    Wallets, sub-wallets, Stripe top-ups and auto-recharge.

  • Budgets with degrade

    Switch to a cheaper model automatically before blocking anyone.

  • Stripe billing

    Metered subscriptions, webhooks (basil + legacy) and CSV invoices.

  • Multi-tenancy & RBAC

    Orgs, roles, invites, audit log — with owner anti-lockout.

  • Rate limiting

    Sliding window per user. Memory, Postgres or Redis stores.

  • Margin & forecasting

    Per-model margins and next-period spend projection.

  • React console

    The dashboard in the screenshots ships with the package.

Included

A console your customers can see

Live replica of the included console — sample data.

Sample console data: $24.32 spend this period, up 65% versus the previous 15 days, 2.0M tokens used, 40% of quota, 31.2k requests. By model: gpt-4o $11.43, claude-sonnet-5 $7.54, gpt-4o-mini $3.65, claude-haiku-4-5 $1.70 — each carrying roughly a 23% margin.

React components · Dark & light themes · WCAG AA · Ships with the package

How it works

Three steps to zero overspend

  1. 1 Install

    Clone the private repo that comes with your license and add it to your workspace.

  2. 2 Wrap the route

    import { withAiGuard } from 'meterkit';
    
    export const POST = withAiGuard(chatHandler, {
      quota: { tokens: 5_000_000, per: 'month' },
    });
  3. 3 Done

    Every request is metered, priced and enforced. The console reads the same store.

Positioning

Watching vs. enforcing

Observability tools (Helicone, Langfuse) tell you what you spent. MeterKit decides whether the request runs at all.

MeterKitObservability SaaSBuild it yourself
Blocks overspend before it happens ✗ — watches, alerts after Eventually
Prepaid credits, quotas & billing Weeks of work
Your data stays in your database ✗ — their servers
Pricing One-time Monthly, per event Your time

EARLY BIRD −25% · FIRST 20 SALES OR 2 WEEKS

One-time. Yours.

Lite

Free

MIT · open source

  • Metering core (withMeter)
  • OpenAI extractor & cost calc
  • Basic dashboard
  • Memory store
Coming soon on GitHub

Agency

€149 (was €199)

Unlimited client projects

  • Everything in MeterKit
  • Use in unlimited client projects
  • Priority support (24h)
Buy Agency

One-time payment · 1 year of updates · 14-day refund, no questions · VAT handled at checkout

FAQ

Questions, answered

What exactly do I get?

Private repo access with the full TypeScript source (no obfuscation), Drizzle migrations, the React console, docs and the test suite. You own what you deploy.

What does “1 company” mean in the license?

One company (or individual) can use MeterKit in any number of its own products, with unlimited developers. Client work for third parties requires the Agency tier, which grants your clients rights limited to the delivered project.

How do updates work?

You get every release for 1 year via the private repo. Versions you received are yours forever — the license to use them is perpetual.

What is the refund policy?

14 days, no questions asked. Lemon Squeezy (the merchant of record) processes refunds and handles VAT.

What support is included?

Email support at dev@meterkit.dev, best-effort within 48h. Agency licenses get priority responses within 24h.

What are the requirements?

Next.js 14+ or any Node 18.17+ backend, TypeScript. Postgres is optional (a memory store ships for dev). Stripe is optional — quotas, credits and budgets work without it.

How much latency does it add?

Almost none — the guard runs in-process, with no proxy hop through a third-party service. Only the pre-call checks sit on the hot path; usage recording happens after the response. Measured with the micro-benchmark that ships in the repo: under 0.05 ms overhead with the in-memory store, and about 1 ms against a local Postgres (add your app-to-database round-trip in production). Both are noise next to an LLM call.

Why one-time and not a SaaS?

MeterKit runs inside your app with your data. No per-event fees, no vendor between you and your users, nothing to keep paying for the code you already run.

Does it work with providers other than OpenAI and Anthropic?

Yes. Usage extractors are duck-typed — anything that reports token usage can be metered, and per-model pricing is fully configurable.