AI API Cost Calculator
Estimate costs for LLM prompts, completions, image generation, audio transcription, text-to-speech, embeddings, and full RAG pipelines. Supports batch API discounts, prompt caching, and reasoning tokens across 40+ models from OpenAI, Anthropic, Google, DeepSeek, Mistral, Meta, Qwen, Cohere and xAI.
Workload Configuration
Cost Breakdown
How AI API Cost Is Calculated
Chat / Text Generation
Monthly cost = requests × [(input tokens × input price) + (output tokens × output price) + (reasoning tokens × reasoning price)]. If prompt caching is enabled, the cached portion of input is billed at the cache-read rate (typically 50-90% cheaper). If using OpenAI's Batch API, both input and output are discounted 50% for asynchronous workloads.
RAG Pipeline
RAG cost = (embedding cost for new documents) + (queries × retrieved-chunk tokens × input price) + (queries × output tokens × output price). Embedding cost is usually negligible; the dominant cost is the LLM call that includes retrieved context as input.
Image Generation
Cost = images × per-image price. DALL-E 3 charges $0.04/image; Stable Image Ultra charges $0.08/image; Stable Image Core charges $0.03/image.
Audio Transcription (Whisper)
Cost = audio seconds × $0.0001/second = $6/hour.
Text to Speech (TTS)
Cost = characters × per-character price. TTS-1 is $0.000015/char (~$15 per 1M chars); TTS-1 HD is $0.00003/char.
Embeddings
Cost = tokens × per-token price. Text Embedding 3 Small is $0.02/Mtok; Large is $0.13/Mtok.
Cost Optimization Tips
- Use prompt caching: Move static system prompts and long context to a cached prefix. OpenAI and Anthropic offer 50-90% discounts on cached tokens.
- Use the Batch API: For non-latency-sensitive workloads (overnight processing, bulk classification), OpenAI's Batch API gives 50% off.
- Right-size your model: Use a cheap model (GPT-5 Nano, DeepSeek V3) for routing/classification and a flagship only for complex reasoning.
- Compress prompts: Remove politeness filler, limit few-shot examples to 2, and compress multi-line context into bullets.
- Cap output tokens: Set max_tokens to the minimum you need. Output tokens are typically 4-8× more expensive than input.
- Cache embeddings: Don't re-embed unchanged documents. Store embeddings and only recompute for new/changed content.
FAQ
How is AI API cost calculated?
Cost = (input tokens × input price) + (output tokens × output price). Prices are quoted per token. Batch API and prompt caching reduce cost. This calculator handles all of these automatically.
What is the cheapest LLM API?
DeepSeek V3 at $0.28/$0.42 per Mtok and GPT-5 Nano at $0.05/$0.40 per Mtok are among the cheapest production-grade APIs. For free tiers, see Google's Gemini API free tier and Groq's free Llama inference.
How much does RAG cost?
RAG cost = embedding cost for chunks + LLM cost for (retrieved context + query + response). Embedding cost is usually negligible (cents). The dominant cost is the LLM call that includes retrieved context as input tokens. Use RAG mode in this calculator for an accurate estimate.
Does this calculator support prompt caching?
Yes. Enter the percentage of your prompt that hits the cache. The calculator blends the standard input rate with the cache-read rate automatically.
Can I calculate costs in INR?
Yes. Select INR (or EUR, GBP, JPY, etc.) from the currency selector. All prices convert from canonical USD using static exchange rates.