AI / Engineering journal

What Drives the Cost of LLM Features

The model price list tells you almost nothing about what an AI feature will cost. Here is what really drives the bill and how to keep it predictable.

Sylantix Engineering Team7 min read
A developer reviewing API usage and monthly costs on a laptop.
Sylantix / Engineering journalLLM · Cost · AI
In this article 7 sections
TL;DR

Key takeaways

  • Input tokens usually outweigh output tokens, because every request carries its instructions, history and retrieved documents.
  • Retries, long conversations and agent loops multiply cost quietly; they rarely show up in a demo.
  • Measure cost per feature and per active user from the first release, not after the first surprising invoice.
  • The cheapest fixes are a smaller model for easy steps, a shorter context and caching answers that repeat.

Estimating the cost of a feature

An AI feature that costs little in staging can become expensive once customers use it regularly. Request volume matters, but so do the length of the input, repeated calls, retrieved documents and retries.

To estimate costs, trace what each request sends to the model and how often that request occurs. Then track spending by feature so you can see which changes would make a difference.

What you are paying for

Tokens in, tokens out

Language models bill by tokens, roughly pieces of words, and they count both directions: the text you send and the text the model writes back. Output tokens are usually priced higher, which leads people to focus on keeping answers short.

That instinct is only half right. In most product features the input is far larger than the output. A request carries the system instructions, the user's question, any conversation history and often a chunk of documents retrieved to ground the answer. The model then writes a paragraph. The paragraph is not where the money goes.

Context grows when nobody is looking

Context size is the quiet driver. A chat feature that resends the whole conversation on every turn gets more expensive with each message. A retrieval system that pulls ten long passages "to be safe" pays for all ten on every question, even when two would do. A prompt template that collected a few more examples during development is now attached to millions of calls.

None of this is visible in a single request. It shows up as an average cost per request that drifts upward over weeks.

Retrieval payloads

If your feature uses retrieval-augmented generation, the retrieved text is part of the input. Good retrieval is cheaper than bad retrieval, not only more accurate: precise chunks mean fewer tokens per answer. The trade-offs between grounding a model in your documents and changing the model itself are covered in RAG vs fine-tuning, and cost is one of the stronger arguments there.

Retries and failures

Every timeout, malformed response or validation failure that triggers a retry is a second bill for the same answer. Retry logic is necessary. Unbounded retry logic is a cost leak, and it tends to fire hardest exactly when the provider is under load.

Agent loops

Agents are the biggest multiplier. One user request can turn into a planning call, several tool calls, a reflection step and a final answer, each with the growing transcript attached. A loop that usually takes four steps occasionally takes twenty. The average looks fine; the tail is where the money is.

Model choice

The most capable model is not the right default for every step. Classification, routing, extraction from a clean form and short rewrites rarely need the largest model on the menu. Using it everywhere is the simplest way to pay several times more than necessary for the same result.

Measure before you optimize

You cannot manage a number you do not record. The minimum useful setup logs, for every model call:

  • which feature and which step made the call
  • the model used
  • input and output token counts
  • latency and whether the call was a retry
  • an anonymous user or account identifier

From that you can answer the questions that matter. What does one summary cost on average, and what does the slowest tenth cost? Which feature accounts for most of the spend? How much does an active user cost per month, and how does that compare to what they pay?

Cost per active user is the figure to bring to a pricing discussion. A feature can be cheap per call and still unprofitable if a small group of heavy users calls it constantly.

The levers, in the order we would pull them

Trim the context

Start here because it is free and usually gives the most back. Cut instructions that no longer change behavior. Summarize old conversation turns instead of resending them. Retrieve fewer, better passages. Strip boilerplate from documents before they reach the prompt. Each removed paragraph is removed from every future call.

Use a smaller model for easy steps

Split the feature into steps and ask which ones need real reasoning. A small model can decide whether a question needs a search, pull fields out of a structured message or check whether an answer cites a source. Reserve the large model for the step where quality visibly depends on it. Test the split on real examples before switching, so the saving does not come with a quality drop you only notice later.

Cache what repeats

Many products ask the same thing over and over: the same help article summarized, the same product description rewritten, the same classification for identical inputs. Caching exact repeats is straightforward. Some providers also discount repeated prompt prefixes, which rewards keeping the fixed part of your prompt at the start and stable.

Batch work that can wait

Not every call needs an answer within a second. Nightly enrichment, bulk tagging and report generation can often go through slower, discounted batch processing where a provider offers it, or simply be scheduled outside peak hours.

Put limits on loops and retries

Cap the number of agent steps, the number of retries and the total tokens a single request may consume. When a limit is hit, fail gracefully and log it. Those logs tell you which inputs make the system wander.

What does not reduce cost

Streaming makes a response feel faster because text appears as it is generated. The tokens are the same, so the bill is the same. Shortening the visible answer helps a little; shrinking the input helps a lot more. Switching providers for a slightly lower list price helps less than fixing a bloated prompt.

Cost tracking belongs in the first release

The usual plan is to ship, see if people like the feature and optimize later. The problem is that "later" arrives as an invoice, and by then nobody remembers which prompt change doubled the context.

Adding per-call logging in the first release costs a day or two of work. It turns every later decision into a comparison of numbers instead of a debate. It also lets you set a budget alert before the first surprise rather than after it.

When we build LLM features we treat the cost dashboard as part of the feature, alongside the evaluation set that checks answer quality, because the two trade off against each other and you need to see both. The LLM integration page describes how that service layer is usually set up.

Forecasting before you scale

Before opening a feature to everyone, run a simple forecast:

  1. Take the measured average and slow-tail cost per request from a pilot group.
  2. Estimate requests per active user per month from that same group, not from a guess.
  3. Multiply by the number of users you expect, then add a margin for retries and for users who adopt the feature more heavily than the pilot did.
  4. Compare the result with what those users pay, or with the cost of the manual work the feature replaces.

If the numbers do not work, you have options before launch: a smaller model, a shorter context, a usage limit per plan, or a premium tier for heavy use. All of those are easier to introduce at launch than to impose afterwards.

Measure a representative week

Pick your most used AI feature and pull one week of calls. Sort them by input tokens and read the ten largest requests in full. In most products this single exercise reveals an oversized prompt, a forgotten conversation history or a retrieval step that sends far more text than it needs to. Fix that first, then put the logging in place so the next drift is visible the day it starts.

Facing this in your own product?

Describe your situation in a few sentences. Our engineering team replies within 24-48 hours on business days, and the first 30-minute consultation is free.

Sylantix Engineering Team

Written by the senior engineers who build these systems for clients: backends, AI features, mobile apps and the infrastructure under them. Questions about your own case go straight to them.

About the team →