What Does an AI Feature Cost to Run?

An AI feature doesn't have the near-zero marginal cost of normal software. Each use costs money, and that changes how you should price and design it. The sums are easy once you see them.

What Does an AI Feature Cost to Run? — Troiana insight cover

In short

To estimate an AI feature's running cost, multiply input tokens by the input price and output tokens by the output price, then multiply by requests per month. A simple summary may cost a fraction of a cent, while a chat or agent can cost many cents per conversation. Add 20–50% as a planning buffer for retries, testing and heavy users, and measure real usage straight after launch.

The basic formula

Model APIs charge by the token, separately for input and output. See what a token is. As a rough guide for English, one token is about three-quarters of a word.

Cost per request =
  (input tokens  / 1,000,000 x input price) +
  (output tokens / 1,000,000 x output price)

Monthly cost = cost per request x requests per month

Prices vary enormously across models and change often. So the examples below use illustrative round numbers, not real price quotes: $1 per million input tokens and $5 per million output tokens for a mid-priced model. For current numbers, see LLM API pricing compared.

Example 1: summarising support tickets

Each ticket: 1,000 input tokens and 150 output tokens.

  • Input: 1,000 / 1,000,000 x $1 = $0.001
  • Output: 150 / 1,000,000 x $5 = $0.00075
  • Per ticket: about $0.00175

At 10,000 tickets a month, that's about $17.50. Cheap, even with a generous margin for error.

Example 2: a chat assistant with retrieval

A chat sends the history again on each turn, so costs climb with length. Assume six turns, using retrieved documents:

TurnInput tokensOutput tokens
13,000300
23,600300
34,200300
44,800300
55,400300
66,000300
Total27,0001,800
  • Input: 27,000 / 1,000,000 x $1 = $0.027
  • Output: 1,800 / 1,000,000 x $5 = $0.009
  • Per conversation: about $0.036

At 20,000 conversations a month, that's $720. A tenfold increase in usage or a much more expensive model changes this completely.

Example 3: an agent

An agent calls the model repeatedly, with growing context. Suppose a task takes 12 steps, and the input averages 15,000 tokens, with 500 output tokens per step:

  • Input: 180,000 tokens = $0.18
  • Output: 6,000 tokens = $0.03
  • Per task: about $0.21

That's about 120 times the ticket summary. A thousand tasks a day costs roughly $6,300 a month, before retries. This is why agents need limits. See what an AI agent costs per month.

Cost per use, log scale
Ticket summary$0.00175
Six-turn chat with retrieval$0.036
Agent task$0.21
$0.001$0.01$0.1$1
The three worked examples, at $1 input and $5 output per million tokens. The agent is about 120 times the summary.

The hidden extras

Your estimate will probably be low if it leaves out:

  • Retries and failures. You often pay for a failed attempt. See how to handle LLM failures gracefully.
  • Heavy users. A small number of users can generate a large share of usage.
  • Long documents. One big PDF can cost more than a hundred normal questions.
  • Hidden prompts. System prompts and tool definitions count on every request, and they can be large.
  • Reasoning tokens. Some models charge for internal thinking.
  • Embeddings and vector search, if you use retrieval.
  • Other services, such as speech, images, web search and OCR.
  • Evaluations and testing. Your own test runs cost money, too. See how to evaluate an LLM feature.
  • Monitoring and logs. See how to log and debug AI features.
  • Human review, if you need people to check the output.
  • Abuse. If it's free and open, someone will try to use your API as their own. Add rate limits.

As a planning rule of thumb, add 20–50% to your initial estimate until you've got real data. This isn't a measured figure, simply a sensible margin for early planning.

How to reduce the cost

In rough order of effort:

  1. Use the smallest model that passes your tests. The price gap between models can be over tenfold. See how to choose an LLM for your product.
  2. Limit output. Output tokens cost more, so set sensible maximums and ask for concise answers.
  3. Use prompt caching for repeated context. Discounts can be substantial on the cached part. See how to control AI API costs.
  4. Trim the context. Send only relevant documents, and summarise or cut long histories.
  5. Use batch processing for anything that doesn't need an immediate answer. Several providers offer discounts.
  6. Cache complete answers for common questions.
  7. Route by difficulty. Send simple requests to a cheap model.
  8. Cap usage, with limits per user and per day.

Pricing your product

Traditional SaaS assumes close to zero cost per user. AI doesn't. So work out:

  • Cost per active user per month, both typical and heavy. Your typical user may cost $0.50 and your heaviest user $50.
  • Gross margin at your planned price. Payment fees and hosting come out of this as well.
  • What your free plan costs you. Each free user has a real cost.

Common ways of protecting your margin:

ApproachWorks forWatch out for
Fair-use limits within a planMost SaaSPeople hate surprise limits, so be clear
CreditsVariable, heavy useUsers find them confusing
Add-on for AI featuresOptional featuresLower adoption
Usage-based billingAPI-like productsUnpredictable customer bills
Bring your own keyTechnical usersMore setup for them

Prices have generally been falling, but don't build a business on the assumption that they'll keep doing so. New top models often cost more, and providers can change their offerings.

How to measure it after launch

Log for every request: the model, input and output tokens, cost, user or account, and feature. Then look at:

  • Cost per feature
  • Cost per active user, including its distribution
  • Your most expensive 1% of requests
  • Daily spending, with an alert for spikes

Set a hard spending limit with your provider, too. A loop bug can burn through a month's budget in a night.

Compare this against the value you're getting: time saved, tickets deflected, or conversions gained. A $0.20 task that saves ten minutes of staff time is a bargain, whereas a $0.01 feature that nobody uses is a waste. See also is an open-source or hosted model cheaper?

If you'd like help estimating and controlling your AI feature's costs, book a call.

Common questions

How much does it cost to add AI to an app?

Running costs can range from a fraction of a cent per request for a simple summary to many cents per task for an agent. The total depends on model choice, how much text you send, and usage. Build costs are separate.

How do I calculate LLM cost per user?

Log real token usage per user, then multiply by your model's input and output prices. Before launch, estimate tokens for a typical session and how many sessions you expect. Look at heavy users separately, because averages can hide your biggest costs.

Why are AI chat features expensive?

Each new message usually resends the conversation history and any retrieved documents, so input tokens grow with length. Output tokens also usually cost more than input. Trimming history, using prompt caching and setting length limits can reduce the cost considerably.

How can I reduce my AI feature's cost?

Use the smallest model that passes your tests, limit output length, use prompt caching and batch processing, send less context, cache common answers and cap usage per user. Measure before and after, so you can be sure that quality hasn't dropped.

Have something worth building right?