Toni MaxxToni Maxx

One AI Gateway With Credits Per Person

ai product

  • Built with
  • Firebase
  • Node.js

AI features cost money to run, so every product needs a way to limit them. I did not want to build that limit again for each product.

So my products share one AI gateway, and the credits belong to the person. This note explains the idea in plain words.

The problem with one limit per site

If every site counts its own AI use, a person has no single picture of their total. Each site also has to build keys, limits and usage tracking from scratch. That is plumbing, and it is the same plumbing every time.

Credits that follow the person

The gateway is part of IDUnify, the account I use across my sites. I wrote about the sign-in side in why one sign-in across my sites. The AI side builds on the same account.

The rule is short. Credits belong to the person, not to the site. A product that wants AI asks the gateway and does not rebuild the plumbing. Keys, limits and usage tracking live in one place.

Two limits do the work:

  • An allowance that belongs to you, not to a single site.
  • A daily limit per person, which protects the bill.

The account page shows AI credits, and the person can see where they were spent. That is the part I care about most. A limit you cannot see feels like a wall. A meter you can see feels fair.

Try it

This toy uses made-up numbers. Slide the number of requests and watch the two meters. The three services are fictional. Notice that none of them has its own meter.

Interactive · toy

Credits belong to the person, not to the site. Every service draws from the same allowance and the same daily limit. The numbers in this toy are made up.

  • Each sample request spends one sample credit.
  • The allowance meter fills across all three fictional services.
  • The daily meter fills too. At its limit, the rest wait until tomorrow in every service.

What it keeps small

The gateway counts usage. It does not need your questions to do that. As I said in the sign-in note, it keeps usage counts, not the text of questions and answers. AI can be wrong, and the products say so.

Where you can see it

My Sidekick Note and อปท.com projects use this kind of AI. The AI features service describes how I set it up for other products, and the IDUnify part of the demo page shows the account screen. For more small interactive pieces, see the widgets.

If you need this

If you plan AI features in more than one product, decide the limits first: who owns the credits, what the daily cap is, and what the person can see. Then build the gateway once. I am happy to talk it through.

Talk about your project