How to reduce the running cost of an AI feature

Updated · 5 min read

Measure the cost of each completed task first

The cost of a single request tells you little. A customer question may trigger a search, a classification, a draft and a check, and each of those is a separate model call with its own input and output. Track the tokens used at each step, the number of retries and whether the task succeeded.

The number to manage is the cost per completed task: total model spending divided by the tasks that finished correctly. Set spending alerts in your provider's console, and check the usage figures in your own logs weekly until the pattern is clear.

Send fewer, better tokens

Input tokens are usually the largest part of the bill, because the same instructions and reference text are often sent with every request. Trimming them is the cheapest saving you can make, and it rarely hurts quality if you test each change.

  • Cut instructions to what the model needs. Remove repeated rules and examples that testing shows do no work.
  • Send only the fields a step needs, not the whole customer record or the whole email thread.
  • Summarise long conversation history rather than replaying every earlier message.
  • Keep reference documents out of steps that do not use them.
  • Compare the prompt length against the output quality on your test set before and after each change.

Match the model to each step

Not every step in a workflow needs the largest model. Routing a message to the right team, checking whether a field is present or converting a form into a fixed format often works well on a smaller, cheaper model. Drafting nuanced replies or handling ambiguous cases may need a stronger one.

Test each step separately on your own cases. Model lineups, prices and capabilities change, so compare the current list on the provider's pricing page before you commit to a choice.

Limit output length and stop runaway loops

Output tokens are usually priced higher than input tokens, and an agent that loops can multiply the cost of one task many times over. Put simple limits in place before launch, so a bad case cannot run up a bill overnight.

  • Set a maximum output length for each step, and ask for a concise format such as a short label or a fixed set of fields.
  • Cap the number of steps an agent may take for one task, and stop it when that cap is reached.
  • Limit retries to a small fixed number, and change the request on each retry rather than resending it unchanged.
  • Detect a tool call that repeats with the same input and output, and stop it.
  • Set a spending ceiling per run or per day, and alert a person when it is close.

Batch and reuse work where the task allows

Some work does not need an instant answer. Overnight classification of a backlog, weekly report drafts and bulk tagging can often go through a provider's batch or asynchronous option, which many providers price lower. Check the current terms, including turnaround time, before you design around them.

Reuse work you have already paid for. If the same product question or policy lookup appears again and the answer has not changed, store the result in your own system and return it without a new call. Provider-side prompt caching, where it is offered, rewards a fixed prompt layout and is a separate topic.

Mistakes that quietly raise the bill

Most unexpected AI bills come from a small set of habits. Review your feature against this list before launch and again after every model update.

  • Sending the largest model to every step by default.
  • Retry loops with no limit, or retries that resend the same failing request.
  • Pasting whole documents when a search for the relevant passage would do.
  • Testing against live traffic on an expensive model with no budget set.
  • Forgetting background jobs, scheduled runs and test scripts that still call the API.

How Hundred Seas helps

Hundred Seas builds AI agents and AI CRM systems on Claude and on OpenAI models. Model choice is one of our main levers on running cost, so we select the model for each task on cost, speed, quality and where the client's data must stay. We are a registered partner in Anthropic's Claude Partner Network and an OpenAI partner.

Work begins with a scope step of about one week at a fixed price, ending in a written plan and a firm quote. The build then arrives in two to four weeks of weekly releases, and a monthly run plan tracks the software's usage and keeps it current.

Questions

Is the cheapest model always the best choice?
No. The cheapest model can fail more often, and each failure costs a retry, a review or a customer complaint. Compare cost per completed task on your own test set, including the failure rate. A model that costs more per call can still be cheaper per finished task.
How do I estimate the cost before I launch?
Take a sample of real tasks, count the tokens at each step, and multiply by the current prices on your provider's pricing page. Add the expected retry rate and some margin for longer cases. Then compare the estimate with the real figures after the first weeks and correct it.
Does prompt caching always save money?
No. Providers set their own rules for cache writes, cache lifetime and minimum size, and the savings depend on how often the same prefix is reused. Read the current documentation, then measure your cache hit rate in the usage data before you count on a saving.
What if costs rise after a model update?
Where your provider lets you pin a model version, pin it and move on deliberately. Re-run your test set on any new version, and compare cost per completed task and quality side by side before you switch. Costs and behaviour can both change, so watch both.
Should I host my own model to save money?
Usually not at small scale. Hosting, updating and monitoring a model carries its own costs and staff time. Start with a provider's API, measure your real usage, and revisit the question only when your volume and requirements clearly justify the extra work.

Have a project in mind?

Tell us what you want to build. We reply with a plan, not a sales call.

AboutHow to reduce the running cost of an AI feature