1. Scope
Calculates per-user contribution margin for an AI-powered product by netting subscription revenue against token costs, hosting, and other per-user expenses. It does not model enterprise negotiated rates or prompt-caching discounts.
2. Inputs and outputs
Inputs
- subscriptionPrice number (currency/mo)
- avgInputTokensPerUser number (tokens/mo)
- avgOutputTokensPerUser number (tokens/mo)
- modelInputCostPerMillion number (currency)
List price per 1M input tokens.
- modelOutputCostPerMillion number (currency)
List price per 1M output tokens.
- hostingPerUser number (currency/mo) default: 0
- otherPerUser number (currency/mo) default: 0
Outputs
- aiCostPerUser
Blended input/output token cost at the user's usage profile.
- totalCostPerUser
aiCostPerUser + hostingPerUser + otherPerUser.
- grossMargin
(subscriptionPrice − totalCostPerUser) / subscriptionPrice.
Engine source: src/lib/ai-product-margin-calculator/engine.ts
3. Formula / scoring logic
ai_cost_per_user = (input_tokens * input_cost_per_m + output_tokens * output_cost_per_m) / 1_000_000
total_cost = ai_cost_per_user + hosting_per_user + other_per_user
gross_margin = (subscription_price - total_cost) / subscription_price 4. Assumptions
- Users are priced uniformly. Tiered or usage-metered pricing requires running the tool once per tier.
- Token costs are list prices; negotiated commitments or prompt-caching discounts are applied manually on top.
- Hosting-per-user is amortised from a fixed plan (e.g. a $20 Vercel Pro plan at 1,000 users = $0.02/user).
5. Data sources
- Anthropic pricing as of 2026-04-24
- OpenAI pricing as of 2026-04-24
- Google Gemini pricing as of 2026-04-24
6. Known limitations
- Prompt caching and context-window reuse can cut effective cost by 30–80%. The tool does not infer this — users must reduce the avgInputTokens figure to reflect it.
- Does not model failure-mode costs: retries, long-running tool calls, or regenerations inflate token counts in production.
- Pricing is a snapshot; if the as-of date is stale, consult the live vendor page before making a pricing decision.
7. Reproducibility
Input
price = $29/mo, input = 400K tokens, output = 100K tokens, Claude Sonnet list, hosting = $0.02, other = $0.
Expected output
ai_cost ≈ $2.70, total_cost ≈ $2.72, gross_margin ≈ 90.6% (as of 2026-04-24 list pricing).
8. Change log
- 2026-04-24 methodology page first published. Pricing snapshot 2026-04-24.