Every Kwacha the AI Spends (Part 3 of 4)
There's a Postgres table that records every single AI model call this platform makes — what it cost, and why. No silent AI spend, ever.
Under the Hood — Part 3 of 4. (Start at Part 1.)
Every kwacha the AI spends
There is a Postgres table that records every single AI model call this platform makes: what it cost, which session and task it belonged to, and when it happened. No silent AI spend. Ever.
We built it early, and on purpose, because AI is the first infrastructure cost that can run away from you invisibly. A tight loop, a runaway agent, a feature that got a little too chatty — and you find out on the invoice, weeks later, when it's too late to do anything but wince. So we treated AI spend the way we treat money: a first-class ledger, metered, grouped, capped, and reconciled.
How it works is boring in the best way. Every call writes to the usage ledger. Admins watch cost accrue live and reconcile it against wallets and campaigns. Agent runs draw from a metered credit wallet with a hard cap — automation literally cannot overspend, because the wallet says no before the model does.

And here's the part that's genuinely fun to show: because the AI work is metered and mostly runs on a flat-fee backend, the cost curve bends the wrong way. Output went up while cost-per-unit went down. That's backwards from how software usually behaves — and it's most of the reason a project this size is even viable. I broke the numbers down in the Delivery Efficiency series if you want the receipts.
Honest note: metering everything adds a little overhead to every call — a few milliseconds of bookkeeping per model invocation. I'll take that trade every day of the week. On a platform that's supposed to be trustworthy with other people's money, "we can account for every cent the machine spent" is not a nice-to-have.
Metering money is one thing. Metering the truth on a live map — making sure a fake truck never shows up as a real one — is another. That's the last one.