Check out the Build Series. Part 1 | Part 2 | Part 3 | Part 4 | Part 5
Three days after shipping SMART Draft to all DraftKit users, my Lovable AI Gateway costs had tripled in a single week. Not doubled. Tripled. I opened Supabase and had zero visibility into which creators were calling the AI feature, how many times, or what it cost per call.
I pulled the analytics_events table and manually counted every draft_generated row. There were 28 total across all users since launch. Twelve of them were mine.
My own testing sessions, which I had never filtered out of production logs, accounted for 43% of every AI call the feature had ever made. The cost spike was me.
The relief lasted about ten minutes. Then I realized I had shipped two more AI features, SMART Match and Collab Metrics, with no cost attribution, no per-user caps, and no way to tell a real cost spike from my own noise.
The next one could be real and I still would not know until the invoice hit.
The problem is not the cost. The problem is the blindness. You cannot make a product decision about pricing, throttling, or feature design when you have no idea who is consuming what.
If you are building any AI feature on a flat subscription, cost attribution is the first thing you need to fix, not the last. If you want to audit how your current AI feature handles cost exposure before it becomes a line item you cannot explain, reach out at hello@elenacalvillo.com.
Flat-Rate AI Is Quietly Building a Deficit Most Builders Have Not Found Yet
GitHub Copilot was losing an average of $20 per user per month on a $10 subscription, with power users hitting $80 per month. They had 4.7 million subscribers. The math on that is a baseline monthly deficit in the nine figures.
They eventually moved to token-based billing, which triggered a backlash because nobody had priced it in at design time.
The pattern shows up everywhere AI is priced flat. The FinOps Foundation’s State of FinOps 2026 found that 98% of practitioners now manage AI spend, up from 31% just two years ago.
That jump is not because AI costs suddenly became manageable. It is because enough teams got surprised that tracking AI spend became mandatory.
For DraftKit, the specific failure modes I had not built for were:
✅ High-frequency users: a creator refreshing SMART Match every hour is a different cost profile than one who runs it once a week
✅ Agentic call chains: SMART Draft pulls two RSS feeds, calls the AI Gateway, parses JSON, and stores results in one request, meaning every call is more expensive than it looks in isolation
✅ No fallback cost: if the AI call fails halfway through, I still pay for input tokens, but the user sees an error and retries
The Pattern Is the Same Everywhere
Builders ship the AI feature first and figure out cost attribution second. The feature timeline creates the gap: you spend weeks on the happy path, ship it, and the cost structure gets reviewed when the invoice arrives. By then, the behavior is baked in and changing it requires a user-facing policy, not a silent engineering fix.
This is especially true on Lovable, where shipping fast is the point. The cost question almost always comes after the first real usage spike.
Why Your Workflow Misses This
Most PMs building with AI tools track cost at the account level, not the user or feature level. You know what you are spending total but not what SMART Draft costs per creator-day, or which feature is 3x more expensive than you assumed. That account-level view is enough for a billing audit but useless for a pricing decision.
The decision you actually need to make is: if I give every user unlimited access to this feature at $X/month, does that math work at scale? You cannot answer that question without per-user, per-feature attribution.
The Approach I Follow
✅ Log every AI call with creator ID, feature, model, token counts, and derived cost. This goes into an
ai_usage_logtable in Supabase at the end of every successful edge function call. Failed calls still get logged with astatuscolumn so I can track token waste from retries separately.✅ Run a pre-flight budget check before every AI call fires. A Postgres function called
check_ai_budget()runs at the top of each edge function before the AI Gateway is touched. If the creator is over their daily cap, the function returnsfalseand the edge function returns a 429 with adaily_limit_reachederror code that the UI handles gracefully.✅ Set caps per feature, not per account. SMART Match has a lower daily cap than SMART Draft because it runs more frequently and the cost per call is more variable. Treating all AI features as one budget bucket hides the expensive ones.
✅ Decouple the cap from the pricing tier. The daily cap is a cost protection mechanism, not a feature gate. Pro users get a higher cap than free users, but the cap exists for both. This means if pricing changes, I adjust one number in a config table, not logic spread across three edge functions.
✅ Build the fallback before you need it. The 429 response has a structured error payload with
error: 'daily_limit_reached'and aresets_attimestamp. The Lovable UI reads that and shows a specific message instead of a generic error. I built this on day one of the attribution system, not after the first user complained.



