How to bill an AI app by usage
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.
- AppCustomer actsA description is written.
- EventApp sends itTo Ruba, with the customer.
- MeterRuba countsFilter, then add up.
- PriceUnits become moneyOn a subscription product.
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.
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 },
}],
});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.
Great for One unit per action, like a request or a document.
Watch for Every matching event counts the same.
Great for Units that differ in size, such as words or tokens.
Watch for The property must be a number on every event.
Great for Billing on a peak or an average, not a total.
Watch for Check that it matches the invoice you want.
Rules to know before you launch
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.
- Ruba: usage-based billingChecked 23 Nov 2026
- Ruba: record billable activityChecked 26 Nov 2026
- Ruba: metersChecked 26 Nov 2026
- Ruba: usage creditsChecked 26 Nov 2026
- Ruba: TypeScript SDKChecked 26 Nov 2026
- Ruba: pricing and feesChecked 26 Nov 2026