How to bill an AI app by usage

Short answer

To bill an AI app by usage, send an event each time a customer does something billable, count those events with a meter, and attach a metered price to a subscription product. Ruba pays you to your own bank. The feature is new, so test it in the sandbox first.

The chain, in one picture

Ruba bills usage in three steps: record an event, count it on a meter, then charge for it or draw down credits. Nadeem in Lahore runs an AI tool that writes product descriptions. He wants to charge for what customers actually use. Here is the chain: action, event, meter, price, invoice.

From a click to an invoice
  1. AppCustomer actsA description is written.
  2. EventApp sends itTo Ruba, with the customer.
  3. MeterRuba countsFilter, then add up.
  4. PriceUnits become moneyOn a subscription product.
Figure 1From Ruba’s usage billing docs. The feature is new, so test in the sandbox.

Step 1: send an event

Each event has a name, a customer and optional metadata. Use your own customer ID as the external customer ID. Send an external ID per event to avoid double counting.

TypeScript
import { Ruba } from "@getruba/sdk";

const ruba = new Ruba({
  accessToken: process.env.RUBA_ACCESS_TOKEN ?? "",
  server: "sandbox",
});

await ruba.events.ingest({
  events: [{
    name: "summary_created",
    externalCustomerId: "user_42",
    metadata: { words: 1800 },
  }],
});
Figure 2Adapted from Ruba’s docs. It needs the events:write scope. Use your own names.

Names can have up to 128 characters. Metadata supports up to 50 keys, with keys up to 40 characters and values up to 500 characters.

Step 2: choose how a meter counts

A meter does two jobs. A filter picks which events belong, using clauses joined with and or or. An aggregation turns them into one number.

CountEach event
ProducesNumber of events
ExampleDescriptions written
Property neededNo
Best forActions

Great for One unit per action, like a request or a document.

Watch for Every matching event counts the same.

Figure 3From Ruba’s meters docs. Tap a function.

Rules to know before you launch

Ruba does
Deduplicate events with an external ID
Show a customer estimate and invoice
Use credits before billing overage
Ruba does not
Edit or delete an accepted event
Issue retroactive invoices for late events
Block a customer at zero credits
Figure 4From Ruba’s event ingestion docs.

Late events count in the period when Ruba received them, even if their timestamp is older. Plan your queue so events are sent soon.

What to do next

Build and test in the sandbox, then apply for Ruba early access. Ruba charges 4% + $0.50 per payment, plus 0.5% on subscriptions, and has no monthly fee. Read how prepaid credits work in prepaid credits for an API, or the money side in making money from an AI wrapper.

Bill for what is used, and your margin stays healthy. Ruba asks for no company and charges nothing by the month. The rate for your AI app is 4% + $0.50 per sale, locked once you are approved in early access, for as long as the account stays open and in good standing. A fee Ruba never told you about is refunded, and Ruba pays you $100. Terms apply. See the early-access deal.

Questions people ask

What do I need to set up usage billing?

Three things: an event your app sends, a meter that counts matching events, and a subscription product with a metered price. Ruba has each one. usage-based billing is new, so test it in the sandbox first.

Can I fix a wrong event?

No. An accepted event cannot be edited or deleted. Send a new correcting event instead.

How do I avoid counting the same event twice?

Send an external ID with each event. Ruba uses it to deduplicate, and the response reports inserted and duplicate counts. In the TypeScript SDK the field is externalId.

What if an event arrives late?

Billing-period assignment uses the time Ruba received the event, not the timestamp you sent. Ruba does not issue retroactive usage invoices or credits for late ingestion.

Does Ruba stop a customer when credits run out?

No. Event ingestion does not enforce a balance. Your application reads the balance and decides whether the customer may continue.

Sources

We check these when we update this guide. Rules can change, so check them yourself before you decide.

A note from FaizanHi, I’m Faizan, the founder of Ruba. I built it so people anywhere, from Pakistan, India and Bangladesh to the UK, the EU and the US, can sell software to the world and get paid at home.I wrote these guides to be as fair as I can. But I built Ruba, so I’m about as neutral as a parent at a school play. That’s why every fact has a source you can check.
Early access is live.

Sellers approved now keep 4% + $0.50 per sale locked for as long as they sell, plus +$100 if we ever charge a fee we never told you about. No company and no monthly fee. You are paid to a bank in your own name, in PKR, INR, BDT or 51 other currencies, whenever you ask, from $10. A payout costs $2 up to $200.

Applying is not approval. Terms apply.
All guides

Can’t find your country or currency? Email support@getruba.com.

This guide is general information, not legal, tax or financial advice. Other companies named here set their own rules, which can change. Check their websites before you decide.