Skip to content
Built in Lahore, PakistanHow we check the math
mathbehind

AI Feature Cost Calculator

Estimate the monthly API bill for a chatbot or AI feature from your users and conversations, including the cost of re-sending chat history.

By Muhammad Ahmad, Software EngineerLinkedIn· figures checked

Your numbers

Prices and fees in this tool are in US dollars.

User messages, each followed by one AI reply.

tokens

Sent with every message. Include any documents you add as context.

tokens

About 45 words is 60 tokens.

tokens

Monthly API cost

$391.20

Cost per active user

$0.391

Cost per conversation
$0.0391
Input tokens per conversation
10,560
Output tokens per conversation
1,800
Conversations per month
10,000
Annual API cost
$4,694
The math behind it
  1. Input tokens

    6 × 800 + 6 × 60 + 360 × 6 × 5 ÷ 2equals10,560

  2. Output tokens

    6 × 300equals1,800

  3. Per conversation

    10,560 ÷ 1M × $2.00 + 1,800 ÷ 1M × $10.00equals$0.0391

  4. Per month

    $0.0391 × 10,000 conversationsequals$391.20

Per-token prices look tiny, but a chat feature multiplies them in a way that is easy to miss: every message re-sends the whole conversation so far. This calculator models that growth, so you can price an AI feature before the first invoice arrives.

Figures checked by Muhammad Ahmad against OpenAI API pricing, Claude API pricing and Gemini API pricing. Prices and rules change, so confirm with the official source before relying on them. How we check the math

How it works

Each message sends the system prompt, the new user message and, in a normal chat, every earlier message and reply. So the input for message 6 includes messages 1 to 5 and their replies.

For m messages, total input tokens are m × system + m × user + (user + reply) × m(m − 1) ÷ 2. The last term is the chat history, and it grows with the square of conversation length.

Cost is input tokens ÷ 1,000,000 × the model's input price, plus output tokens ÷ 1,000,000 × its output price. Prices come from the same verified dataset as the AI API Cost Calculator.

A worked example

A 6-message chat with an 800-token system prompt, 60-token messages and 300-token replies uses 10,560 input tokens and 1,800 output tokens. On Claude Sonnet 5 ($2 in, $10 out per million), that is $0.0391 per conversation. At 1,000 users having 10 conversations a month, the bill is $391.20 a month, or $0.39 per user.

More examples

The default chatbot workload, 10,000 conversations a month, costs $391.20 on Claude Sonnet 5 or GPT-6 Sol, and $19.56 on GPT-6 Luna.

Sending no history (one-off requests) cuts input from 10,560 to 5,160 tokens per conversation, and the Sonnet 5 bill from $391.20 to $283.20.

Common mistakes

  • Leaving out conversation history, which is resent with every message.
  • Pricing on average users when heavy users drive most of the cost.
  • Forgetting reasoning tokens, billed as output on models that think.
  • Not rechecking after model price changes, which were frequent in 2026.

Questions people ask

Why does conversation length matter so much?

Because history is re-sent with every message, a 12-message chat costs much more than twice a 6-message chat. Capping history, summarizing older turns, or starting fresh conversations keeps costs predictable.

Does prompt caching change the result?

Yes. Most providers now discount repeated input such as a long system prompt when it is cached. This calculator uses standard prices, so treat the result as an upper estimate if you use caching.

How do I count tokens?

In English, one token is roughly three quarters of a word, so 100 words is about 133 tokens. Use the Token and Word Count Converter to translate your own prompt lengths.

How much does it cost to run an AI chatbot?

Multiply the tokens in an average conversation by the model's prices, then by conversations per month. Long conversations cost far more than short ones, because the whole history is resent with every message.

How can I reduce the cost of an AI feature?

Cache the fixed system prompt, trim or summarise long chat histories, route simple requests to a smaller model, and set sensible limits on conversation length or messages per user.

Guides

In the news