Home / Insights / AI in Practice
The Economics of Inference: What Makes AI Cost Money to Run
Tokens, batching, caching and model choice: where the running costs of AI applications come from.
Training makes headlines, but an application pays for inference every time it is used.
What is being paid for
Hosted models usually charge per token, with different prices for input and output. Output is typically dearer because tokens are generated one after another. When you host a model yourself, you pay for hardware time whether or not it is busy.
Diagram by O&O Consulting.
Where the engineering gains come from
Generating text requires keeping a cache of attention data for each request, and managing that memory well determines how many requests a machine can serve. The vLLM system introduced a paging technique that reduced waste and raised throughput. Speculative decoding has a small model propose several tokens that the large model verifies together, speeding generation without changing the distribution of outputs.
What application builders control
- Remove unnecessary instructions and documents from prompts.
- Ask for concise, structured output.
- Send easy requests to a small model and escalate hard ones.
- Cache answers or shared prompt prefixes where this is safe.
- Process non-urgent work in batches.
- Cap retries and the number of steps an agent may take.
Budgeting
Estimate requests per month, tokens per request and the share needing escalation or human review. Then test the estimate against logs from a pilot, since real users write longer inputs and try more often than expected. Set alerts and hard spending limits, which also protect against abuse of a public form or chat window.
Limitations and open questions
Prices and model options change quickly, so a calculation made today will date. Design so that the model can be swapped and keep the test set that tells you whether a cheaper option is good enough. The lowest price per token is not the lowest cost if answers need rework.
References
- Kwon, W. et al. (2023). "Efficient Memory Management for Large Language Model Serving with PagedAttention." arxiv.org/abs/2309.06180
- Leviathan, Y., Kalman, M. and Matias, Y. (2022). "Fast Inference from Transformers via Speculative Decoding." arxiv.org/abs/2211.17192
- Chen, L., Zaharia, M. and Zou, J. (2023). "FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance." arxiv.org/abs/2305.05176
This article is general information, not financial, legal or investment advice. AI research and rules change quickly; check the cited sources for the current position.