What this lesson is

Most AI features lose money silently. The PM watches DAU climb, the CFO watches the OpenAI bill climb faster, and three quarters in someone in finance asks the question that should have been asked on day one: "What's the gross margin on this thing?" Nobody knows. The dashboards never tracked it.

This lesson turns AI cost from a black box into a four-line spreadsheet. By the end you can compute cost per task, pick a model mix that hits your margin floor, and choose between five pricing models without flinching when the CFO asks why.

The shape of an AI feature's economics is unusual: variable cost dominates. Unlike SaaS — where serving the 1,000th user costs almost the same as the 100th — every AI request burns tokens. Every token costs money. Pricing has to reflect that or you're shipping an expensive charity.

The PM's pricing job, in one line:
know your variable cost per task, know your willingness-to-pay, and pick a pricing shape where #2 stays comfortably above #1 — even on a bad day.

What you actually pay for, when AI runs

Every AI vendor's pricing page looks intimidating until you realize there are really only six things you're being charged for. Most PMs only think about the first two. The other four are where margins go to die.

📥
Input tokens
Everything you send the model — system prompt, retrieved docs, chat history, the user's question. Long context = expensive context.
📤
Output tokens
What the model writes back. Usually 3–5× more expensive per token than input. A chatty model is a costly model.
🏷️
Model rate
The per-million-token price set by the vendor. Flagship models cost 10–30× more than minis. This is where routing pays off.
🔎
Retrieval cost
Embedding the query, hitting the vector DB, fetching docs. Small per request, but if you retrieve on every keystroke, it stacks.
💾
Prompt cache savings
Vendors offer 50–90% discounts on input tokens that repeat across requests (system prompts, knowledge base). Free margin if your prompts are stable.
🔁
Retry overhead
Failed JSON parses, refusals, timeouts, automated retries. Easily 10–25% on top of your "happy path" cost. Always budget for it.
The PM's first instinct should be: "What's in my prompt that doesn't need to be there?" Trim 30% of input tokens before you negotiate model price. The cheapest token is the one you never sent.

The cost-vs-quality picture

Every model is a dot on the same chart: pass rate on your golden set (Y) versus cost per task in naira/rupees (X). The launch gate is a horizontal line. Anything below the line doesn't ship — no matter how cheap. Anything above it ships in priority of cheapest first.

Cost per task (₦) → Pass rate → Launch gate 80% ₦0 ₦5 ₦15 ₦35 ₦60+ mini-A (66%, ₦1.5) below gate — fails mini-B + cache (84%, ₦4) cheap and shippable smart-routed mix (89%, ₦12) best margin path flagship-only (93%, ₦42) overkill — eats margin frontier (94%, ₦60)
The cheapest dot above the line wins.
Not the highest pass rate. Quality past the gate is invisible to the user; cost past the gate is visible to the CFO. Don't pay for invisible quality.

Scenario — Amara at NaijaCart Lagos

🛒
Real-world scenario
"AI search must have ≥40% gross margin" — and Amara has 10 weeks

Amara is the PM for AI search at NaijaCart, a Lagos-based marketplace with 2.3M monthly active shoppers. The CTO shipped a flagship-model search assistant in beta last quarter — pass rate is great, NPS is up, but the finance team just produced a heat map showing the feature is running at negative 12% gross margin. Every search costs more than the user generates in margin on the order it leads to.

Amara has 10 weeks and a CFO mandate: AI search must have at least 40% gross margin by end of quarter, or the feature gets pulled. The first uncomfortable thing she discovers when she opens the cost dashboard? Nobody had ever computed cost per query. The team had been measuring "cost per month" against "GMV uplift" and calling it a win. The unit economics had never been done.

How Amara computes cost per query

Step one is boring math. Pick a typical query, count the tokens at each stage, multiply by the rate. The number is rarely what anyone guesses. Here's a real-shape breakdown for one NaijaCart search ("show me cheap rice under 5kg, free delivery to Yaba"):

Cost per query — NaijaCart product search (flagship-only baseline)
Single-query cost decomposition
Input tokens (prompt + 8 retrieved products + history)
×
2,400 tok @ ₦0.0042/tok
₦10.08
Output tokens (ranked list + explanation)
×
320 tok @ ₦0.0210/tok
₦6.72
Retrieval (embed query + vector DB lookup)
+
flat per call
₦1.40
Retry / refusal overhead (~18% rework)
+
0.18 × happy-path cost
₦3.27
Avg cost per query (flagship baseline)
=
sum
₦21.47

Step two: multiply by per-user volume to get the monthly hit. The average NaijaCart shopper runs 14 AI searches/month. The plan tier sells for ₦750/month. Here's where the margin floor lives:

Monthly unit economics — flagship baseline
Per-user economics at current model mix
Avg cost per query
×
14 queries/user/month
₦300.6/user
Plan price per user
−
user revenue
₦750.0/user
Gross margin
=
(750 − 300.6) / 750
59.9%
Breakeven price (40% margin floor)
=
cost / (1 − 0.40)
₦501/user min

That's the chart Amara walks into the CFO meeting with. Notice what just happened: at flagship-only with no optimisation, the per-user economics are already healthy on the ₦750 plan. The "negative 12% margin" came from the team running flagship for the entire free tier, where there's no plan price to subtract from. The fix isn't necessarily a cheaper model — it's a different pricing model. We'll get to that.

The four-strategy bar chart she shows the team

Before that, Amara stress-tests four ways to run the same feature, holding quality above the 80% gate:

Cost per task by strategy (₦, lower is better) Flagship-only ₦42 Mini-only (fails gate) ₦3 — but 66% pass Smart-routed mix ₦12 Cached + routed ₦7 — winner ↑ ~83% reduction from flagship to cached+routed
What Amara does with this: ships cached + smart-routed as the production strategy. Same 89% pass rate as flagship for the queries that matter. ₦7/query × 14/month = ₦98/user/month. On a ₦750 plan, that's an 87% gross margin — well past the floor, with room for the free-tier subsidy.

Five pricing models — and where each one bites

Cost per query tells you the floor. Pricing model tells you whether the ceiling is even reachable. The five shapes below cover ~95% of how AI features are actually monetised. Pick one deliberately; don't drift into one by accident.

Pricing model Best for Risks Margin profile
Free / loss-leader Acquisition feature in a marketplace or ad-supported product. Cheap models, capped per user. Variable cost compounds with virality; abusers (bots, prompt-stuffers) can blow the bill 10×. Negative on the feature itself. Must be subsidised by another revenue line.
Included in plan SaaS where the feature lifts retention. Predictable per-user usage. Power users cost 5–10× the median; if you priced on the median, the long tail wrecks margin. Healthy if you cap usage and route smart. ~40–70% gross margin typical.
Usage-metered Power-user tools, developer APIs, B2B analytics where customers expect a meter. Bill shock. Customers churn when an unexpected ₦40k arrives. Add a soft cap and pre-alerts. Strongest margin and most predictable. ~50–75% if priced ≥3× cost.
Tiered Mass-market consumer products. Free / Plus / Pro with credit caps per tier. Tier definition is hard. Too cheap a Plus tier and you eat margin; too expensive and nobody upgrades. Mixed by tier. Free is loss-leader; Pro should be 70%+ to subsidise the rest.
Freemium with throttle Products where AI is a teaser to the paid product (search, generation, summaries). Defining "the moment to throttle" without making it feel hostile. UX work, not just billing work. Free: subsidised. Paid: 40–60%. Depends entirely on how aggressive the throttle is.
Amara's choice for NaijaCart:
tiered. Free shoppers get 5 AI searches/month on the cached+mini path (cost ≈ ₦20/user, easily covered by ad inventory). Plus subscribers (₦750/mo) get 50 searches on the smart-routed mix. Pro merchants (₦4,500/mo) get unlimited. The free tier is now the loss-leader it was always supposed to be — not the entire product.

The AI connection

How real AI teams actually run this

Strong AI teams instrument three things from day one: tokens-in, tokens-out, and model used — tagged on every request, written to a cost dashboard alongside latency and quality. The PM looks at a single chart of cost-per-task overlaid on pass-rate weekly. When cost drifts up (longer prompts, more retries, vendor price change) or quality drifts down, alerts fire before the CFO ever sees a bill. The pricing-model decision is then re-evaluated quarterly against actual usage distribution, not the launch-day guess. cost-per-task model-routing prompt-caching gross-margin tier-design

Mini challenge — price an AI feature in 20 minutes

Pick one AI feature you (or your team) ships

1. Estimate cost per task

Write down a typical request: how many input tokens (system prompt + retrieved context + user message), how many output tokens, retrieval cost, retry overhead. Plug in current vendor rates. You should land on a single ₦/₹/KSh number per task. Most PMs are off by 2–3× the first time. That's the point.

2. Multiply to monthly

How many tasks does a typical user run per month? Multiply. That's your monthly variable cost per user. Compare it to whatever the user actually pays you (or the value they generate). What's the gross margin? Is there one?

3. Pick a pricing model and defend it in two lines

Free, included, usage-metered, tiered, or freemium? Write the one-line "why this fits" and the one-line "what could go wrong". If you can't write the second line, you don't actually understand the choice yet.

Interview questions

Easy How do you compute cost per task?
+
Sum four pieces: (input tokens × input rate) + (output tokens × output rate) + retrieval cost + retry overhead. Input includes system prompt, retrieved context, and chat history — not just the user's message. Output is usually 3–5× more expensive per token. Retry overhead is typically 10–25% on top of the happy-path cost; budget for it explicitly. The number you get is the floor for any pricing decision.
Easy What's a sensible gross margin floor for an AI feature?
+
For a paid AI feature in a SaaS context, 40–60% is the usual floor — well below traditional software margins (75–85%) because variable cost is real. For consumer-tier free AI, the feature itself runs negative; it has to be subsidised by another revenue line (ads, marketplace take rate, conversion to paid). The right number depends on the company's blended target margin and whether the feature is acquisition or expansion.
Medium What's prompt caching and when does it save money?
+
Prompt caching is when the vendor stores the processed form of a prefix you send repeatedly — typically your system prompt and any stable knowledge-base context — and discounts those tokens 50–90% on subsequent calls. It saves money when (a) your prompts have a long stable prefix, (b) you reuse it within the cache TTL (usually minutes), and (c) the variable part comes after the stable part. It does not help if every request is unique end-to-end, or if you keep editing the system prompt during an A/B. Putting the user's question last and the system prompt first is the cheap, free win.
Medium A power user runs 30× the median usage and is destroying your margin. What do you do?
+
Three moves, in order. (1) Look at the distribution before reacting — if it's two whales, deal with them individually; if it's a long tail, the product needs systemic change. (2) Add a soft cap with pre-alerts: at 80% of fair-use, show a friendly "you're a power user, here's the Pro plan" upsell. Throttle, don't surprise. (3) If the use case is genuinely high-value, introduce a usage-metered or Pro tier priced at 3–4× variable cost. The mistake is to do nothing and let blended margin decay quietly across the customer base.
Hard Your CFO says the AI feature must have positive contribution margin from day one. How do you respond?
+
Don't fight; reframe. Two questions back to the CFO: "Day one of what — beta, GA, or scaled state?" and "Contribution margin against which revenue line?" Most "day-one positive margin" demands assume the AI feature is its own business. It usually isn't — it's a retention or conversion driver for the broader product. So the right metric is often blended contribution margin: AI feature cost vs. the lift it produces in the underlying revenue (subscription retention, GMV, conversion). If you can show "every ₦1 in AI cost generates ₦3.20 in incremental GMV margin", that's positive contribution even if the feature is "free" to the user. If you can't measure that lift, the CFO is right and the feature has no business existing yet — go build the lift measurement first. Either way, the answer is data, not negotiation.

Test your knowledge

Question 1 of 5
Which of these is usually the most expensive token type per million?
Question 2 of 5
A model has 94% pass rate at ₦60/task; another has 89% at ₦12/task. Your launch gate is 80%. Which ships?
Question 3 of 5
Which pricing model is highest-risk for "bill shock" without guardrails?
Question 4 of 5
Cost per query is ₦18, user runs 10 queries/month. To hit a 40% gross margin floor, minimum price per user must be at least:
Question 5 of 5
When does prompt caching most reliably save money?
0
/5
You can defend AI margins to the CFO now.

Common mistakes

Pricing on the median user
The median runs 6 queries/month; the 95th percentile runs 80. If you priced for the median, the long tail eats the entire margin. Always price against the cost-weighted distribution, not the count median.
Forgetting retry overhead
Failed JSON parses, refusals, and timeouts add 10–25% to "happy path" cost. Teams that don't budget for it ship features that look profitable in QA and bleed money in production.
Locking in flagship before evals
"Let's just use the best model and optimise later" — but later, you've priced the feature and trained users on response quality. Walking back is hard. Run the eval on cheaper models first; reserve flagship for queries that need it.
Treating free as costless
"Free tier" doesn't mean free to serve. A free AI feature that goes viral can 10× the bill in a week. Always cap free usage by request count or daily token budget — soft cap, friendly upsell, never a silent cliff.

Key takeaways

  • Cost per task = (input × rate) + (output × rate) + retrieval + retries. Compute it before you price anything.
  • The cheapest model above your launch gate wins. Quality past the gate is invisible; cost past the gate is not.
  • Smart routing + prompt caching routinely cuts cost 70–85% versus flagship-only, with no measurable quality drop.
  • Pick a pricing model deliberately — free, included, usage-metered, tiered, or freemium-throttled. Each has a different failure mode.
  • The gross margin floor is the line your pricing must clear on a bad day, not an average one. Stress-test against power users, retries, and vendor price hikes.
  • If you can't show the lift the AI feature drives in the underlying revenue line, the CFO is right to question whether it should ship at all.
Africa & India's Best AI Academy
🤖 AI-first 🎓 Placement Assistance

You can now price AI features.
Next — measure whether they're worth it.

Join the Best AI Program: The AI-Era Agentic Engineer — 5 months, fully online, with placement assistance. Week 1 is free.

Explore The AI-Era Agentic Engineer →