How to Calculate AI Cost per Project (A Real Case Study)

By Darus S Alfatah · 2026-11-07 · Optimasi · 9 menit

How to Calculate AI Cost per Project (A Real Case Study)

Author note: After logging per-feature cost for a month, we found one small endpoint consumed nearly half the budget.

Focus of this article

This article teaches how to calculate the total cost of one feature/project from request volume and average tokens, including retry cost.

Read also: Price per Million Tokens: Budgeting AI Costs in Practice · What Is a Token? The Unit Behind Every AI Bill

Introduction: AI Cost Is Often Invisible

Many teams are shocked when their AI bill balloons. The reason is simple: AI cost is variable — it depends on how many tokens are processed, not how many users you have. A feature that looks small can drain a big budget if every request sends long context or produces rambling answers. This article shows how to calculate it concretely, with examples.

The Base Unit: Tokens

Every AI provider bills per token — a chunk of words, roughly 3–4 characters in Indonesian or about 4 characters in English. Prices are usually per million tokens, split between input tokens (what you send) and output tokens (what is generated). Output is almost always more expensive, two to five times.

cost = (input_tokens × input_price + output_tokens × output_price) / 1,000,000

Case Study: Customer-Service Chatbot

Suppose an online store has a chatbot handling 1,000 conversations per day. On average each conversation: 500-token system prompt, 300-token history, 100-token question, 250-token answer. So 900 input and 250 output tokens per conversation.

  • Daily input: 1,000 × 900 = 900,000 tokens.
  • Daily output: 1,000 × 250 = 250,000 tokens.
  • Monthly (30 days): 27 million input + 7.5 million output.

At example prices of Rp 4,000 per million input and Rp 20,000 per million output: input Rp 108,000, output Rp 150,000, about Rp 258,000 per month. It looks small, but rises fast if the system prompt grows to 2,000 tokens.

Factors That Spike Cost

  • Long system prompts sent on every request.
  • Unbounded conversation history that grows each turn.
  • Rambling output without a max_tokens cap.
  • Expensive models used for trivial tasks.
  • Uncontrolled retries that re-bill failed requests.

Cost-Cutting Strategies

  1. Two-tier routing — a cheap model decides, the expensive model only for hard cases.
  2. Summarise history — store a summary, not the full transcript.
  3. Cap output — set max_tokens to real needs.
  4. Prompt caching — static parts billed cheaper when cached.
  5. Monitor per feature — so one feature does not swallow the whole budget.

Budgets and Alerts

Set token budgets per feature and per user. Send automatic alerts when usage hits 80% of budget. This gives time to react before the bill exceeds the plan. Also track cost per customer so subscription pricing stays profitable.

Common Calculation Mistakes

First, forgetting the system prompt tokens sent every time. Second, ignoring reasoning tokens on reasoning models that are invisible in the output. Third, assuming input prices are the same across models. Fourth, not leaving margin for retries and failures.

When an Expensive Model Is Actually Cheaper

An expensive model often finishes a task in one try, while a cheap one needs three tries plus corrections. In that case the expensive model can be cheaper overall. Always compare cost per completed task, not just price per token.

A Simple Estimator

Make a spreadsheet: model column, input price, output price, average input tokens, average output tokens, and requests per month. Multiply and sum. Update whenever usage patterns change. This simple estimator prevents bill surprises and eases comparison between models.

FAQ

How many tokens per page of text?

About 500–700 tokens per A4 page of Indonesian, depending on density.

Is streaming cheaper?

No, the rate is the same. Streaming changes perceived speed, not cost.

Does caching really save money?

Yes, when the prompt prefix does not change. Cached parts are billed cheaper by many providers.

Which model is cheapest?

It depends on the task. Compute cost per completed task, not just price per token.

What if usage spikes suddenly?

Use quotas, automatic alerts, and a fallback to a cheaper model for light tasks.

Are reasoning tokens charged?

Yes. On reasoning models, "thinking" tokens are billed even though they do not appear in the answer.

Key Takeaways

  • Cost is per token, input and output separated.
  • Output is pricier; control its length.
  • Long system prompts are the biggest hidden waste.
  • Compute cost per completed task, not per token alone.
  • Set budgets and alerts before the bill explodes.

Conclusion

Calculating AI cost is simple once you know the pattern: multiply tokens by price, separate input and output, then multiply by frequency. Then cut cost with routing, summaries, and output caps. Start from BankAI, which shows transparent pricing so your calculation is accurate from day one.

Example: calculate before launching: Suppose your feature runs 10,000 times a month, averaging 400 input and 200 output tokens per call. That is 4 million input plus 2 million output tokens. Multiply by the per-token rate of the chosen model, then add a margin. This number is far more honest than guessing "probably cheap".

Frequently Asked Questions

What is the optimization goal here?

This article covers reducing wasted tokens and cost without hurting output quality, making API usage more efficient.

Does this optimization lower answer quality?

No, when applied correctly. The focus is prompt and token efficiency, not reduced quality.

Where can I see my token usage?

In the BankAI dashboard, with per-model and per-period breakdowns.

Sources & References

About the author

Darus S Alfatah — Founder & Writer

Darus S Alfatah is the founder of BankAI. He builds and operates the LLM API gateway that serves Indonesian developers, and writes about LLM integration, gateway architecture, and using AI practically and cost-effectively. Every guide is tested in a real environment — including code, configuration, and token calculations — before it is published, and updated when provider documentation or pricing changes.

Editorial policy

Related articles

🚀 Ready to Use the All-in-One API Key?

Sign up, top up with QRIS, and start building with ChatGPT, Claude, DeepSeek and every other model through one key.

🔑 SIGN UP NOW · Pricing