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.
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.
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.
Guides
- How to Price an AI Feature So It Stays ProfitableStart from cost per active user, not cost per token. Here's how to estimate it, including chat history, and turn it into a price with a healthy margin.
- Why AI Chat Costs Grow Faster Than Conversation LengthEvery new message in a chat resends the whole conversation as input. That makes long conversations much more expensive than the sum of their messages.
- How to Estimate LLM API Costs Before You ShipAPI bills come from input and output tokens priced separately. With three numbers per request you can estimate a monthly bill and compare models before writing any code.