Skip to content
AlianHubFreeOur open-source project management tool: Kanban, sprints, time tracking and team chat.Try it free
AI5 min read

How to Estimate LLM API Costs Before You Build: A Per-Task Model for Product Teams

Most AI budgets are guesses until the first invoice arrives. This per-task method turns tokens, call counts and volume into a monthly cost you can plan around, before you write any code.

  • ai
  • cost-saving
  • roi
  • engineering
  • strategy

The first month of an AI feature in production often ends with the same surprise: the invoice. Not because the model was expensive, but because nobody estimated how many calls each user action actually makes, or how long the prompts had grown.

You can avoid most of that surprise with a simple spreadsheet and an hour of thinking. The trick is to estimate cost per task, not per token or per month, and only then multiply by volume.

Why per-month estimates go wrong

A typical first estimate goes like this: "We will have 10,000 users, each will ask maybe 20 questions a month, at a few cents each." It sounds reasonable and is usually off by a wide margin, for three reasons.

  • One user action is rarely one call. A single chatbot answer may involve a classification call, a retrieval step, the answer itself and a safety check.
  • Prompts are bigger than they look. System instructions, retrieved documents and conversation history are sent again on every call.
  • Agents loop. An agent that plans, uses tools and checks its work can make five to twenty calls for one task.

Step 1: define the task

Pick the unit your users or business care about: one support ticket resolved, one lead qualified, one document processed, one report generated. Everything else is measured per task.

Step 2: list every model call in the task

Write down each step the system performs for one task, and for each step note:

  • Which model it uses (you rarely need your largest model for every step)
  • Input tokens: system prompt + retrieved context + history + the user's input
  • Output tokens: how long the answer or structured output is
  • How many times it runs per task, on average

A rough rule of thumb is that one token is about three quarters of an English word, so a 1,500-word document is around 2,000 tokens. Measure with your provider's tokenizer once you have real prompts.

Step 3: price each call

Every provider lists a price per million input tokens and per million output tokens, and output is usually several times more expensive than input. For each call:

cost = (input tokens x input price + output tokens x output price) / 1,000,000

Prices change often and differ a lot between providers and model sizes, so check current numbers rather than last quarter's blog post. We keep a side-by-side API pricing table on AIFlash, our AI news site, updated daily for exactly this reason.

Step 4: add it up and multiply

Sum the calls to get cost per task, then multiply by expected tasks per month. Here is an illustrative example for a support assistant. The prices are placeholders to show the method, not quotes for any specific model.

  • Classify the ticket with a small model: 800 input + 50 output tokens, once
  • Retrieve and answer with a mid-size model: 4,000 input + 400 output tokens, once
  • Check tone and policy with a small model: 600 input + 50 output tokens, once
  • Retry rate: 20% of tickets need a second answer attempt

If the small model costs $0.20 per million input and $0.80 per million output tokens, and the mid-size model costs $3 and $15, the answer step dominates: about $0.018 per ticket, against fractions of a cent for the two small steps. With retries, call it roughly $0.022 per ticket. At 30,000 tickets a month, that is about $670.

The useful part is not the final number. It is seeing which step drives the cost, because that is where optimisation pays.

Step 5: add the costs people forget

  • Embeddings and re-indexing for retrieval, including when documents change
  • Evals: running your test set on every prompt or model change
  • Development and testing traffic, which can rival production in the early months
  • Peak load: if usage spikes at month end or during sales, plan for it
  • Logging and storage of prompts and outputs, which you need for debugging and audits

Add a buffer of 25 to 50% for the first three months. Real usage always finds paths nobody planned.

Where the savings usually are

Once you can see cost per step, the levers are clear:

  • Right-size models per step. Classification, extraction and checks often run well on small, cheap models. Save the large model for the step that needs reasoning.
  • Trim the context. Send the three most relevant documents, not twenty. Summarise long histories instead of resending them.
  • Use prompt caching where your provider supports it, so a long, repeated system prompt is billed at a lower rate.
  • Batch non-urgent work. Many providers discount batch processing for jobs that can wait.
  • Cap agent loops. Set a maximum number of steps per task and a fallback when it is reached.

Cost versus quality is a measured trade-off

A cheaper model is only cheaper if it does the job. Before switching, run your eval set on both and compare quality and cost per task side by side. Current AI model benchmarks are a good place to shortlist candidates, but your own task data decides.

This is how we approach it on client builds. In our lead qualification agent, the agent engages every inbound lead within 60 seconds across email, web chat and SMS, and booked demos went up 47%. That only works at a cost the business can sustain, which is why we model cost per conversation before we build, not after launch.

Your next step

Take one task your AI feature will handle, list its calls and run the numbers with today's prices. If the result surprises you, it is far cheaper to find out now than on the first invoice. If you would like help modelling cost and quality for a feature you are planning, get in touch with our team. We build production AI systems and hand over all code, prompts and IP from day one.

From the Alian Software team

Tools we use for this

Frequently asked questions

  • Define one task, list every model call it makes, estimate input and output tokens for each call, price each call with the provider's per-million-token rates, sum them to get cost per task, then multiply by expected monthly volume and add a buffer.

Monthly briefing

One short email a month — what we shipped, what we learned, the patterns we'd recommend (and skip). No fluff.

Got a problem like this?

Describe it in the hero — our agent will scope a solution and tell you what a real build would look like.

You're one step away

We'll email you a copy too. No spam; see our privacy policy.