Record tokens and cost for every AI call by user and feature in your database, then see a dashboard of your most expensive users.
Log AI token usage per user so I know who costs what
How it works
- Create a usage table: Vovy asks Claude Code for a Supabase table with user ID, feature, model, input tokens, output tokens and cost, with Row Level Security on.
- Log every call: Claude Code reads the usage numbers each API response already returns and writes a row after every call from your server.
- Price it per model: Vovy adds a small price table per model from the providers' pricing pages, so cost is calculated, not guessed.
- Build a cost view: Vovy writes a SQL view that totals cost by user and by feature for the month, and runs it in the Supabase SQL editor.
- Show the results: A table shows your top 20 users by AI cost next to their plan, so you can spot users who cost more than they pay.
What you provide
- A Supabase project
- Your app's AI code
What you get
- A usage log for every AI call
- Cost per user and per feature
- A list of unprofitable users
FAQ
Don't the provider dashboards show this?
They show totals by key or project, not by your users. Only your own log ties spend to specific customers.
Will logging slow my app?
Barely. The log write is tiny and can happen after the reply is sent.
What do I do with heavy users?
Common moves: usage limits on the free plan, a higher tier for power users, or routing them to a cheaper model.
Related tasks
All tasks