Your Model Bill Spiked. No One Knows Which Feature
Finance got a model invoice nobody can explain. Attribute spend by feature and tenant, set hard caps, and fail closed before the product gets shut off.
By Muhammad Saif and Aashan Khan · Techtribe co-founders
Finance forwarded an invoice. The number is larger than last month by enough that someone asked which feature caused it. Nobody knows. Engineering shrugs at “usage went up.” Product points at a pilot. Support wonders if a customer left a tab open. The vendor console shows tokens and models, not your feature names. Until every model call carries a route, a tenant, and a budget, the bill is a mystery that ends with someone turning the AI off.
This note is attribution and caps. It is not the deep dive on why an AI agent burns tokens and does nothing useful, which is about retry loops and empty tool thrash. Loops matter. After the spike, you still need to know which product surface spent the money and how to stop the next spike without a war room. If you are shaping the LLM layer, that work sits under LLM development. The usual package is a Production MVP: tagged calls, hard caps, and a report finance trusts.
What the invoice cannot tell you
Provider dashboards are built for their billing, not your product taxonomy. You see model, project, maybe API key. You do not see “support draft reply,” “RAG chat,” “nightly embed job,” or “CI summarizer” unless you put those labels in. A single shared key for the whole app guarantees a single line item. Shared keys are convenient on day one. They are opaque on invoice day.
A spike can be healthy. A launch that worked, a pilot that used the product, a migration that re-embedded a corpus. Finance still needs a sentence that names the cause. “AI is expensive” is not a sentence that keeps budget. “The pilot tenant used 60% of the month on chat, under a cap we will set at X” is.
A spike can also be a bug. A webhook that reprocesses forever. A page that calls the model on every keystroke. A fallback that retries three providers. An eval suite in CI on every commit against a paid endpoint. Without tags, those look identical to success.
Attribution that survives the next feature
Pick a scheme and use it on every outbound model call.
Option A: one API key or virtual key per feature. Support drafts get key S. Chat gets key C. Embeddings get key E. The vendor bill splits by key. Rotation and caps become per feature. The downside is key sprawl and the temptation to reuse “just for now.”
Option B: one gateway with mandatory metadata. Every request sends feature, tenant, route, and environment. The gateway rejects calls missing those fields. Logs and cost exports group by them. This is the usual shape once you have more than three surfaces.
Option C: both. Keys for hard isolation of spend; metadata for finer routes inside a feature. Use this when one feature has both interactive and batch paths that need different caps.
Whatever you pick, the rule is the same: a call without identity does not leave your network. Soft documentation (“please remember to tag”) fails the first urgent hotfix. Enforce in code.
Map tenants the same way. A single customer can dominate a bill. If you cannot say which tenant, you cannot have a commercial conversation about usage-based pricing or about a noisy account. Tenant on the call is also how you investigate abuse.
Hard caps beat soft alerts
An alert that Slack-messages at 80% of budget does not stop a loop at 3 a.m. A hard cap that returns an error to the product does. Decide the product behavior when the budget is gone: show a clear message, queue work for tomorrow, or degrade to a non-model path. Do not fail open with a second untagged key “so the site keeps working.” That is how the spike doubles.
Set caps at more than one level. A global monthly ceiling protects the company. A per-tenant daily ceiling protects you from one user. A per-feature ceiling stops a new experimental route from eating the chat budget. Start stricter than you like for pilots. Loosen with data.
CI and internal tools need their own caps and their own keys. A unit test that “just calls OpenAI” on every pull request is a production cost center. Point evals at a budgeted project. Fail the pipeline when the budget is gone rather than silently billing.
How to investigate this month’s spike
Export usage for the spike window. If you have no feature tags yet, group by API key, model, hour, and any project id you do have. Align the timeline with deploys, feature flags, pilot start dates, and marketing campaigns. Interview on-call for retries and incident loops.
Read application logs for the same window: count of model calls per route if the route name exists; average tokens per call; error retries. A jump in calls with flat tokens per call is volume. A jump in tokens per call is prompt or retrieval bloat. A jump in both is a new surface or a loop.
Check batch jobs. Embeddings and nightly digests often dwarf chat. A backfill that re-ran because a migration failed halfway can look like “the product got popular.” It was a script.
Check agents with tools. Each tool round trip may resend a large context. The token-cost post covers the mechanism. For the invoice, mark agent routes distinctly so you can cap them without freezing simple completions.
Write a one-page postmortem for finance: cause, dollars, what you will tag, what cap you will add, owner, date. That page is what keeps the feature alive. Silence is what gets the key revoked.
Product behaviors that keep spend explainable
Show users when they are near a quota if your pricing includes usage. Hidden quotas create support load; visible quotas create predictable bills. For internal copilots, show the team’s remaining daily budget in an admin view. People behave differently when the meter is visible.
Cache where the answer does not need a fresh model call. Identical FAQ prompts, repeated embeddings of unchanged documents, and deterministic transforms should not hit the paid endpoint every time. Caching is not attribution, but it lowers the noise floor so real spikes stand out.
Prefer smaller models for classification and routing; reserve large models for the turns that need them. Route choice should be tagged. “We moved drafts to a smaller model” is a finance-legible sentence only if the draft feature has its own line.
What does not hold
“We will check the OpenAI dashboard weekly” does not hold. Weekly review finds the spike after the money is spent. Caps prevent it.
“The SDK default is fine” does not hold for metadata. Defaults omit your feature names. You must set them.
“One shared key is simpler” does not hold past the first spike. Simplicity without attribution is expensive complexity later.
“Soft limit emails from the vendor” do not hold as a product control. Vendor emails are late and not wired to your UX. Your gateway must enforce.
Blaming “AI is expensive” without a feature map does not hold in a budget meeting. Bring the map or expect a shutdown.
A two-week fix sequence
Week one. Inventory every code path that calls a model, including scripts, CI, and notebooks that use production keys. Assign a feature name to each. Create keys or mandatory gateway metadata. Deploy enforcement that rejects untagged calls in production. Add a global hard cap slightly above last month’s run rate so you do not brick the product while you learn.
Week two. Split caps per top features. Build a simple daily export: feature, tenant, dollars, calls. Share it with finance. Fix the noisiest route. Add a fail-closed message in the UI. Schedule a monthly review where product owns the lines, not only engineering.
If a gateway such as LiteLLM sits in front, treat its version and admin exposure as a security concern too—see patching self-hosted LiteLLM after CVE-2026-136539—but do not confuse a security patch with cost attribution. You need both.
Talking to finance without losing the feature
Agree on a vocabulary: feature names that match the dashboard. Agree on a ceiling for the next cycle. Agree on what happens at the ceiling (feature pauses, not silent overflow). Offer a forecast for a known pilot. Ask for a temporary raise tied to a named experiment with an end date. Finance funds experiments with owners. They cancel mysteries.
If sales promised unlimited AI to a customer, that promise is now a cost center. Either price it, cap it, or renegotiate. Engineering cannot invent margin after the contract ships.
Edge cases that skew the bill
Streaming vs non-streaming accounting differences. Cached tokens that still appear on some invoices. Image or audio modalities priced differently from text. Tool calls that bill the model for large JSON tool results. Provider-side abuse credits that arrive later and confuse month comparisons. Document each in the runbook so a spike investigation does not thrash on accounting artifacts.
Multi-provider routing can move spend between lines without lowering totals. If fallback is on, attribution must log the provider that actually served the call. A fallback that saves availability can still surprise finance when the secondary provider is priced differently. Pin sensitive routes; fail closed when the primary is down if the secondary is not budgeted. The routing lesson sits beside when model fallback sends prompts to the wrong host.
Ownership
Every feature line needs a human owner. The owner approves raising the cap. The owner gets the alert at 70%. The owner is named in the finance export. Unowned spend becomes everyone’s problem and therefore nobody’s. Put the owner in the same place you put the feature flag.
Engineering owns the enforcement mechanism. Product owns the prioritization of which features keep budget when you must cut. Support owns explaining quotas to users. Finance owns the ceiling. Write that down once.
What good looks like next invoice
The invoice still arrives. Beside it sits an internal report that sums to the same order of magnitude, split by feature and top tenants, with anomalies explained in a paragraph. Caps show headroom or intentional full use. No untagged calls in production logs. CI has its own project. Nobody asks “which feature?” because the answer is a link.
Scenarios that show up on real invoices
A sales demo environment left pointed at the production key over a conference weekend. Attendees refreshed a chat that re-sent a thirty-thousand-token system prompt on every message. The demo looked fine. The bill did not.
A data migration re-embedded every PDF in a customer vault after a schema change. The job failed at ninety percent, restarted from zero, and billed the corpus twice. The feature tag was still “chat” because embeddings shared the chat key.
A well-meaning engineer added an “improve this answer” button that silently called a larger model three times per turn. Product analytics showed higher satisfaction. Finance saw a cliff.
A CI workflow summarized every pull request with a paid model. Merge frequency doubled before a launch. Nobody connected GitHub Actions to the OpenAI invoice until the spike review.
A single enterprise tenant enabled an agent with tools. Each tool result pushed a larger context into the next call. Their contract said unlimited AI. Your margin disagreed.
Walk each scenario with your inventory. If any could happen invisibly, you lack attribution or caps.
Building the finance-facing dashboard
Export daily: date, feature, tenant, provider, model, input tokens, output tokens, estimated dollars, call count, error count. Store it in a warehouse or even a spreadsheet fed by a script at first. Perfection is optional. Continuity is not.
Define “estimated dollars” with a versioned price table so a provider price change does not silently rewrite history. Keep raw token counts forever; reprice if needed.
Show week-over-week change. Highlight new features that appear for the first time. Highlight tenants that cross a percentile. Give product owners a filtered view of only their lines.
Add a narrative field: once a week, the spending owner writes two sentences. That habit trains the company to explain spend before finance asks.
Governance for raising a cap
A cap raise is a change request. Who asks, who approves, what experiment it funds, when it reverts. Write the template once. A Slack “can we bump it” without an end date becomes the new baseline.
For customer-facing unlimited plans, connect sales compensation to gross margin on AI usage or you will sell yourself into a hole. Engineering caps cannot fix a contract that forbids caps.
Working with gateways and multiple providers
If you use a gateway, put mandatory metadata at the gateway and deny at the edge. Do not rely on each service remembering headers. If you multi-home providers, normalize feature names across them so “support_draft” is one line even when the vendor differs.
Shadow traffic and eval suites must use a non-production budget. Label them env=eval. Never share the production cap pool with evals.
Checklist you can run tomorrow morning
- List every production model call site.
- Assign feature names.
- Reject untagged calls in one environment.
- Set a global hard cap with a visible user error.
- Send finance a one-page spike explanation for the last invoice.
- Schedule the weekly export.
- Name owners for the top three spending features.
If you cannot finish all seven in a week, finish one through four first. Attribution without a cap still surprises you. A cap without attribution still blinds you. Together they make the feature discussable.
Pricing models that reduce surprise
Seat-based AI add-ons with a fair-use cap, usage-based with visible meters, and flat enterprise with a negotiated pool each change the attribution story. If you sell unlimited, buy unlimited from the provider only if the math works—or stop selling unlimited. Publish internal unit economics per feature: dollars per successful task, not only dollars per thousand tokens. Tokens without outcomes convince nobody.
When a feature cannot pay for itself, product must cut quality, raise price, or remove the feature. Attribution makes that conversation factual. Without it, the loudest opinion wins and finance removes everything.
If this is your app, send the repo.
A 30-minute scope call. We read what is live, name what is dangerous, and quote a fixed scope.
How Techtribe ties model spend to the product
We inventory every path that calls a model, put feature and tenant identity on those calls, and set hard caps that fail closed with a clear product behavior. You get a report finance can read and a list of the noisiest routes to fix first. We do not promise a lower vendor price list. We promise you can explain the next invoice and stop a runaway without shutting everything down by hand.
When the LLM layer still needs a real gateway, tagging, and production controls, that is a Production MVP. Recurring cost and routing work across many features fits a Dedicated Team. The build path is LLM development.
Bring the invoice or usage export, a rough list of AI surfaces in the product, and access to the repo or gateway that makes the calls. If you already suspect one pilot or one job, say so up front. We will confirm with data before we change caps.
The fixed scope for taking a generated app to production is a page per tool: Lovable, Bolt, v0, and Replit.
Questions
Why did our model bill spike with no product launch?
Usually one route grew: a new chat surface, a retry loop, a batch job, a pilot tenant, or a CI job that calls the API. Without per-feature tags or keys, the vendor invoice only shows a total. The spike is real. The mystery is missing instrumentation, not missing spend.
Is this the same problem as an agent burning tokens in a loop?
Loops are one cause. Attribution is the question after the invoice arrives: which product surface and which tenant spent the money. Fixing a single retry bug without tags means the next feature can spike again and you still cannot prove it.
What should we put in place before finance kills the AI feature?
Per-route or per-feature identifiers on every call, a daily or monthly hard cap that fails closed, a dashboard finance can read without opening the vendor console, and an owner for each spending surface. Soft alerts alone do not stop a runaway bill.
What do we bring to a call about a model bill spike?
The invoice or usage export, a list of product routes that call a model, and access to the code or gateway that makes those calls. The first hour is mapping dollars to routes and deciding which caps must exist before the next billing cycle.