How do you estimate the cost of a feature that uses an LLM?
Short answer
Cost = input tokens × input price + output tokens × output price, times the number of tasks per day. Count per completed task, including retries and tool-call rounds.
3 points to say:
- Measure real tokens with the
usagefield or a token-counting API, not by characters; Vietnamese text and a tokenizer change shift the count. - Every tool round resends the whole context; output tokens cost 4–8× more than input tokens.
- Cut in this order: prompt caching → batch → fewer input/output tokens, and only then a smaller model, with quality measured.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.