AI API Cost Calculator
Compare AI API costs across GPT-4o, Claude, Gemini, Mistral and more Β· find the cheapest model for your use case.
How to Use This Calculator
Formula:
Cost per Request = [(Input Tokens Γ Input Price per 1M) + (Output Tokens Γ Output Price per 1M)] Γ· 1,000,000; Monthly Cost = Cost per Request Γ Requests per Day Γ 30
- Choose a mode tab at the top: Cost Estimate for a single model, Model Comparison to rank all 25+ models by monthly spend, or Monthly Budget to reverse-calculate request capacity.
- Select your target LLM (such as Claude 3.5 Sonnet, GPT-4o, Gemini 2.0 Flash, or DeepSeek V3) or pick a Use Case Preset like Chatbot, RAG Q&A, or Code Generation to auto-fill realistic token counts.
- Enter your exact Input Tokens per Request (system prompt + context + user query) and Output Tokens per Request (expected completion + reasoning tokens).
- Set your projected Requests per Day (or Monthly Budget in dollars on the third tab) to compute real-time daily, 30-day monthly, and 365-day annual API costs.
- Use the Filter by Tier toggle (All, Frontier, Mid-tier, Budget) in the comparison table to spot cheaper drop-in alternatives and quantify monthly dollar savings.
Frequently Asked Questions
In standard English prose, 1 token equals roughly 4 characters or 0.75 words, meaning 750 words convert to approximately 1,000 tokens and 1,000 words equal roughly 1,333 tokens. However, code snippets, JSON punctuation, URLs, numeric IDs, and non-Latin languages tokenize far more densely, often consuming 1.5 to 2.5 tokens per word. For production budgeting, measure actual token counts from ten real API responses rather than relying purely on prose word ratios.
LLM inference has two distinct hardware phases: prefill and autoregressive decoding. Input tokens are processed simultaneously in parallel across GPU tensor cores during prefill, making them cheap per token. Output tokens must be generated sequentially one token at a time, reloading massive model weights from high-bandwidth GPU memory on every single step. Because sequential decoding bottlenecks expensive GPU memory bandwidth, providers price output tokens 3x to 5x higher than input tokens.
Commercial LLM endpoints are stateless, so your backend must resend the system prompt and previous messages on every new user turn. If a user exchanges 8 messages averaging 200 tokens per turn, turn 1 sends 200 input tokens, turn 2 sends 400, and turn 8 sends 1,600 input tokensβtotaling 7,200 billed input tokens across the session instead of 1,600. Truncating old turns or summarizing history after 5 turns prevents quadratic cost growth.
No, a model's maximum context windowβsuch as 128K tokens on GPT-4o, 200K on Claude 3.5 Sonnet, or 1M on Gemini 1.5 Proβis a capacity ceiling, not a flat fee. You only pay for the exact tokens sent and returned on each call. However, stuffing 50,000 tokens of unpruned documents into every RAG call instead of retrieving the top 3,000 relevant tokens will multiply your input bill by more than 16x.
Provider prompt caching cuts repeated input token costs by 50% to 90% whenever calls share an identical static prefix, such as a long system instruction block, few-shot examples, or a large codebase document. Meanwhile, asynchronous Batch APIs offered by OpenAI, Anthropic, and Google provide a flat 50% discount on both input and output tokens for non-urgent jobs like nightly classification, entity extraction, or evaluation runs completed within 24 hours.
Pay-per-token serverless APIs are almost always cheaper at low, bursty, or daytime-only traffic volumes because you pay zero during idle hours. Renting dedicated H100 or A100 GPUs at $1.50 to $3.50 per GPU-hour ($1,080 to $2,520 per month per card) typically breaks even only when your sustained 24/7 throughput exceeds 15 to 30 million tokens per day and keeps GPU utilization consistently above 55%.