Chabi

Guide

AI API billing

An AI API where each user's requests are billed to their own plan.

Updated November 2026

What AI billing takes

Charging users for AI by usage sounds simple until you build it. You need to:

  • count tokens per user and per model, and keep a price table for every model up to date;
  • stop a user from overspending while a long reply is still streaming, including two requests at once;
  • sell plans and top-ups, handle failed payments, refunds and sales tax;
  • tell users clearly when they've run out, and let them buy more.

And you still pay the AI provider's bill up front, whether or not your users pay you.

How Chabi bills

Your app calls Chabi with the signed-in user's token instead of your own API key. For each request Chabi:

  1. checks the user's token and that your app is allowed to use their plan;
  2. holds the most the request could cost (its input plus the full output cap), so concurrent requests can't overspend;
  3. forwards it to the model you named, never a substitute, and streams the reply back;
  4. charges what it actually used, from the provider's own usage report, and releases the rest of the hold.

Pricier models use more credits. Every model's price is on the models page, built from the same tables Chabi bills with.

What users pay

PlanPriceCredits a month
Lite$5250
Basic$10500
Pro$201,100
Max$1006,000

Every plan includes every model. Subscribers who need more can top up from $15, and top-up credits never expire. Users pay Chabi, not you: you never handle their payment details.

Errors your app handles

  • 402 insufficient_credits: the user can't cover this request. The error body has an upgrade link to show them.
  • 402 app_limit_reached: the user capped what your app can spend this month. The body links to where they can raise it.
  • 429: too many requests. Wait the seconds in Retry-After.

With the SDK, describeError turns any of these into a kind and a plain-English message:

import { describeError } from "@chabi/js"; try {  const reply = await client.chat.completions.create({ model, messages });} catch (err) {  const e = describeError(err);  if (e.kind === "out_of_credits") showUpgrade(e.message, e.upgradeUrl);  else showError(e.message);}

What you get paid

0.6¢ for every paid credit spent in your app, plus a share of subscribers' unused credits. How earnings work.

Get started