Estimate OpenAI API Cost for a Chatbot

Running a production chatbot on OpenAI costs more than most developers expect when they first move from the playground to production. The key variables are: average input tokens per conversation (system prompt + history + latest message), average output tokens, number of conversations per day, and the model selected. This example models a customer support chatbot and shows the projected monthly cost across GPT-4o, GPT-4o-mini, and GPT-3.5-turbo to illustrate how model selection dominates the cost equation. The single most impactful cost optimization is model tiering: route simple, high-frequency queries (FAQ answers, form field help, basic navigation) to GPT-4o-mini, and reserve GPT-4o for complex reasoning tasks that actually require it. If 80% of queries are simple, this tiering reduces monthly costs by 60-70% with minimal quality degradation. The cost estimator shows the side-by-side comparison for your specific usage numbers. For long-running conversations, conversation history management is the second biggest lever. A conversation that accumulates 20 turns of history has 3,000+ input tokens before the latest user message is even added. Implementing a sliding window (keep the last N turns) or summary compression (summarize old turns to a paragraph) prevents history costs from compounding unboundedly.

Example
Chatbot: customer support assistant
Model: gpt-4o
System prompt tokens: 450
Average conversation turns: 5
Average tokens per user message: 120
Average tokens per assistant response: 280
Conversations per day: 500
[ open in OpenAI API Cost Calculator → ]

FAQ

How does conversation history affect cost?
Every API call includes the full conversation history as input tokens. A 10-turn conversation sends all previous turns on every request, so costs grow quadratically with conversation length. Implement history pruning or summarization for long conversations.
Is GPT-4o-mini good enough for customer support?
For most customer support tasks — FAQ answering, ticket triage, policy lookups — yes. GPT-4o-mini produces excellent results and costs ~15x less. Test your specific use cases carefully before committing to a model.
Does OpenAI offer volume discounts?
OpenAI does not publish volume discounts. For very high-volume usage, contact their sales team. Batch API pricing (50% off) is available for non-real-time use cases.

Related Examples