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
- subscription_price number (currency/mo)
- avg_api_calls_per_day number
Per user. Multiplied by 30 for a monthly call count.
- avg_input_tokens number (tokens/call)
- avg_output_tokens number (tokens/call)
- input_cost_per_million number (currency)
List price per 1M input tokens.
- output_cost_per_million number (currency)
List price per 1M output tokens.
- hosting_cost_per_user number (currency/mo) default: 0
- other_per_user_costs number (currency/mo) default: 0
Outputs
- apiCostPerUser
Per-call token cost × calls per day × 30.
- totalCostPerUser
apiCostPerUser + hosting_cost_per_user + other_per_user_costs.
- grossMarginPerUser / grossMarginPercent
subscription_price − total cost, and that over price.
- apiSharePercent / dominantCostDriver / scaleTiers
API share of cost, the biggest driver, and revenue/cost/margin at 100 / 1K / 10K users.
Engine source: src/lib/ai-product-margin-calculator/engine.ts
3. Formula / scoring logic
cost_per_call = (input_tokens * input_cost_per_m + output_tokens * output_cost_per_m) / 1_000_000
api_cost_per_user = cost_per_call * avg_api_calls_per_day * 30
total_cost = api_cost_per_user + hosting_cost_per_user + other_per_user_costs
gross_margin = (subscription_price - total_cost) / subscription_price 4. Assumptions
- Tokens are per CALL, and the monthly cost multiplies by avg_api_calls_per_day × 30 — not a flat monthly token total.
- 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.
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
subscription_price = $29/mo, avg_api_calls_per_day = 10, avg_input_tokens = 400, avg_output_tokens = 200, input_cost_per_million = $3, output_cost_per_million = $15, hosting_cost_per_user = $0.50, other = $0.
Expected output
cost per call = $0.0042, apiCostPerUser = $1.26 (× 300 calls/mo), totalCostPerUser = $1.76, grossMarginPercent = 93.9.
8. Change log
- 2026-04-24 methodology page first published. Pricing snapshot 2026-04-24.
Worked example
Run live against the same engine this site ships
(/engines/ai-product-margin-calculator.js).
The inputs and outputs below are recomputed on every build and
independently re-verified in CI — they are never hand-authored.
Input
- tool
- ai_product_margin_calculator
- subscription_price
- 29
- avg_api_calls_per_day
- 20
- avg_input_tokens
- 500
- avg_output_tokens
- 1000
- input_cost_per_million
- 2.5
- output_cost_per_million
- 10
- hosting_cost_per_user
- 0.5
- other_per_user_costs
- 0.25
Output
- apiCostPerUser
- 6.75
- totalCostPerUser
- 7.5
- grossMarginPerUser
- 21.5
- grossMarginPercent
- 74.1
- apiSharePercent
- 90
- dominantCostDriver
- AI API
- scaleTiers[0].users
- 100
- scaleTiers[0].totalRevenue
- 2900
- scaleTiers[0].totalCost
- 750
- scaleTiers[0].totalProfit
- 2150
- scaleTiers[0].marginPercent
- 74.1
- scaleTiers[1].users
- 1000
- scaleTiers[1].totalRevenue
- 29000
- scaleTiers[1].totalCost
- 7500
- scaleTiers[1].totalProfit
- 21500
- scaleTiers[1].marginPercent
- 74.1
- scaleTiers[2].users
- 10000
- scaleTiers[2].totalRevenue
- 290000
- scaleTiers[2].totalCost
- 75000
- scaleTiers[2].totalProfit
- 215000
- scaleTiers[2].marginPercent
- 74.1
- insight
- AI API is 90% of your per-user cost ($6.75/mo). At 10K users, that is $67500/month on API alone. Caching responses or using a tiered model approach could significantly improve margins.
Frequently asked questions
- What does the AI Product Margin Calculator calculate?
- 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.
- What inputs does the AI Product Margin Calculator need?
- It takes 8 inputs: subscription_price, avg_api_calls_per_day, avg_input_tokens, avg_output_tokens, input_cost_per_million, output_cost_per_million, hosting_cost_per_user (default 0), other_per_user_costs (default 0). Outputs returned: apiCostPerUser, totalCostPerUser, grossMarginPerUser / grossMarginPercent, apiSharePercent / dominantCostDriver / scaleTiers.
- What formula does the AI Product Margin Calculator use?
- The exact computation is: cost_per_call = (input_tokens * input_cost_per_m + output_tokens * output_cost_per_m) / 1_000_000; api_cost_per_user = cost_per_call * avg_api_calls_per_day * 30; total_cost = api_cost_per_user + hosting_cost_per_user + other_per_user_costs; gross_margin = (subscription_price - total_cost) / subscription_price
- Can I verify the AI Product Margin Calculator with a worked example?
- Yes. With subscription_price = $29/mo, avg_api_calls_per_day = 10, avg_input_tokens = 400, avg_output_tokens = 200, input_cost_per_million = $3, output_cost_per_million = $15, hosting_cost_per_user = $0.50, other = $0. the tool returns cost per call = $0.0042, apiCostPerUser = $1.26 (× 300 calls/mo), totalCostPerUser = $1.76, grossMarginPercent = 93.9.
- Where does the AI Product Margin Calculator get its benchmark data?
- Reference data is sourced from: Anthropic pricing (as of 2026-04-24); OpenAI pricing (as of 2026-04-24); Google Gemini pricing (as of 2026-04-24).
- What can the AI Product Margin Calculator not tell me?
- 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.