My agent, Hermes, talks to me on a Matrix server I run myself. Self-hosting the chat window was a privacy decision before it was anything else, and that setup is a post for another day. What matters here: an agent that chats all day needs a meter. So every LLM call it makes goes through a proxy I wrote — and “wrote” deserves an asterisk, because I’m a lawyer. An LLM helps me code things out; I mostly argue with it until it works. One SQLite file tells me what it spent today.
Each call is tagged with the model and the chat that made it, and the token count is written to the ledger per call, rolled up per feature per day. When the daily total crosses its budget, a Matrix alert fires once that day, not once per call.
The setting that makes this useful: define a daily budget per feature, and the proxy enforces it. Crossing the line fires a proactive notification, and if the budget is actually breached the proxy kills itself. The meter is also the brake. A runaway agent stops burning tokens the moment it crosses its limit, not the next time I happen to open a dashboard.
Dollar costs are computed at read time from a rates table scraped off ollama.com/pricing, peak window and all. One caveat worth knowing: those are list prices, and if your credits are bought below face value the dashboard overstates the drain. The dashboard is a single page with no build step and no external requests, which is rather the point of self-hosting.
The pattern generalises: pass the caller’s identity in a bearer token, write tokens rather than dollars, make the budget a kill switch instead of a suggestion, and never let the meter become another thing you maintain.
