Skip to content
Questions

How do I estimate LLM costs?

Short answer

Multiply the number of requests by the tokens per request and the price per token, and do it separately for fresh input, cached input and output, because each has its own price. Then add retries, agent loops and growth, and check the estimate against real logs as soon as you have them.

Last updated

Step by step

  1. 1List each AI feature and how often it runs: per user per day, per document, per ticket.
  2. 2Measure or estimate tokens per call for the system prompt, context, user input and output. A token counter on real examples beats a guess.
  3. 3Split input into the part that repeats (cacheable with prompt caching) and the part that changes.
  4. 4Count calls per task: an AI agent or a RAG pipeline may make several model and embedding calls per user request.
  5. 5Apply each model's current input, cached input and output prices from the provider's price page.
  6. 6Add a margin for retries, errors and longer-than-average inputs, then multiply by expected volume.

Check it against reality

Estimates are often wrong because conversations get longer, agents take more steps than planned and outputs run long. Log token counts and cost per feature from the first prototype, and recheck the estimate with real traffic.

Cost depends on the token mix, not only the total: an output-heavy feature and an input-heavy one with the same total can cost very different amounts.

Tools

Check it for your case.

Frequently asked

Common follow-up questions.

Where do I find current prices?

On each provider's own pricing page. Our LLM API pricing page lists them side by side with a source and date for each.

Should I estimate per user or per task?

Per task first, then multiply by tasks per user. It shows which features drive cost and where to optimise.

How do I stop costs running away?

Set limits: maximum output length, maximum agent steps, per-user quotas and spending alerts at the provider.

Keep reading

Related questions and guides.

Planning a build? Talk it through.

OceanLab designs and builds production software. Tell us what you are planning and we will reply with how we would approach it.

OceanLab

Enterprise Software Engineering - Human + AI

Languages

Locations

Global Headquarters

21 Merchant Road, 3rd Floor, Singapore 058267

Main corporate office and leadership operations

North America Office

548 Market Street, PMB 12472, San Francisco, CA 94104

Client operations and business development

India Office

402 Shivalik Shilp II, SG Highway, Ahmedabad 380015

Engineering and delivery center

© 2026 - Copyright. All Rights reserved OceanLab