notAcalculator logo

LLM API Cost Calculator

LLM API Cost Calculator

Give us your feedback! Was this useful?

Understanding LLM API Pricing

Every major AI provider charges by token, but the pricing structure goes deeper than a simple per-million-token rate. Costs depend on model tier, input vs output mix, caching, batch discounts, and — critically for modern applications — the number of agentic iterations your workflow performs.

This calculator projects the cloud side of your bill. If you are weighing those API costs against running your own hardware, How to Estimate Local LLM Cost per Token walks through the equivalent math for self-hosting, and the Local LLM Break-Even Calculator finds where the two cross over.

The fundamental cost of a single API call is:

Ccall=Ni×Pi+No×PoC_{\text{call}} = N_i \times P_i + N_o \times P_o
[openai-pricing]

Where NiN_i is input tokens, NoN_o is output tokens, PiP_i is input price per token, and PoP_o is output price per token. Output tokens are 3-6x more expensive than input tokens across all providers because generation requires sequential autoregressive inference, while input encoding can be parallelized[anthropic-pricing].

Token cost estimation is one piece of the AI developer toolkit. The Token Counter Calculator counts the input and output tokens that feed into the pricing model, while the Context Window Calculator sizes the prompts and conversations that fit in a model's context. For analyzing usage patterns statistically, the Statistics Calculator summarizes request distributions, and the Binary Calculator and Hex Calculator handle the numeric and encoded data that requests carry.

For an agentic workflow with kk turns (tool calls, reasoning steps, revisions):

Cagent=i=1k(Ni,i×Pi+No,i×Po)C_{\text{agent}} = \sum_{i=1}^{k} \left(N_{i,i} \times P_i + N_{o,i} \times P_o\right)

A single agentic task with 4 tool calls costs approximately 4x a simple chat completion for the same final content — before accounting for the tool responses themselves, which add input tokens to each subsequent turn.

Model Pricing Breakdown

As of July 2026, the competitive landscape spans four major providers[deepseek-pricing]:

ModelInput ($/1M tokens)Output ($/1M tokens)200K+ SurchargeCached Input
GPT-5.6 Sol$5.00$30.00No$0.50
GPT-5.6 Terra$2.50$15.00No$0.25
GPT-5.6 Luna$0.20$1.20No$0.02
Claude Opus 5$5.00$25.00No$0.50
Claude Sonnet 5$2.00$10.00No$0.20
Claude Haiku 4.5$1.00$5.00No$0.10
Gemini 3.6 Flash$1.50$7.502x >200KN/A
Gemini 2.5 Pro$1.25$10.002x >200KN/A
DeepSeek V4 Pro$0.435$0.87NoN/A
DeepSeek V4 Flash$0.14$0.28NoN/A

Note that Gemini applies a 2x surcharge on prompts exceeding 200K tokens, making it more expensive than the base rate suggests for long-context tasks[google-pricing].

Output pricing per million tokens across 10 models. The spread from $0.28 (DeepSeek V4 Flash) to $30.00 (GPT-5.6 Sol) represents a 107x difference. Cached input pricing reduces effective costs by 90% on applicable models.

The price gap between frontier and budget models has widened dramatically. GPT-5.6 Sol output at $30/M is 107x more expensive than DeepSeek V4 Flash at $0.28/M. Yet for many tasks — classification, formatting, simple Q&A — users report indistinguishable quality between these tiers[openai-pricing]. The art of cost optimization lies in matching the right model to the right task.

Agentic AI Cost Multipliers

Agentic workflows are the dominant growth driver in LLM spending, and they multiply costs in ways traditional chat completions do not. Understanding the cost structure of agentic systems requires modeling three compounding factors.

First, tool call overhead. Each time an agent calls a tool, the tool's response becomes input tokens for the next model turn. A database query returning 50 KB of results consumes approximately 12,500 input tokens per call. With 10 tool calls per task, that is 125,000 input tokens just from tool responses. This is before any reasoning, planning, or output generation.

Second, reasoning chains. Agentic systems generate intermediate reasoning steps that are not visible to the end user but consume output tokens. These reasoning chains vary by model: deep reasoning models like GPT-5.6 Sol generate extensive chain-of-thought before responding, sometimes 2-4x the visible output[anthropic-pricing]. Budget models like DeepSeek V4 Flash generate minimal reasoning, which reduces output costs but may reduce accuracy on complex tasks.

Third, failure and retry cycles. Agentic tasks fail more often than chat completions because the agent depends on external tools that can time out, return errors, or produce unexpected results. Every retry doubles the token consumption for that turn.

The effective cost of an agentic task can be expressed as:

Ceffective=Cbase×k×(1+r)×freasoningC_{\text{effective}} = C_{\text{base}} \times k \times (1 + r) \times f_{\text{reasoning}}
[anthropic-cache]

Where kk is the number of agent turns, rr is the retry rate (typically 5-15%), and freasoningf_{\text{reasoning}} is the reasoning multiplier (1.5-4x depending on the model).

Tool and Environment Cost Comparison

The same model running in different environments produces vastly different cost profiles because each environment injects system prompts, manages conversation state, and handles tool integrations differently[anthropic-cache].

EnvironmentSystem Prompt OverheadAgent Loop OverheadMonthly Premium (5K tasks/day)
Raw OpenAI API0 tokens0 tokens$0 (base)
ChatGPT Plus~600 tokensNo tool calls$20 fixed
Claude Code~1,200 tokens2-4 tool calls/task~$150
OpenCode~1,800 tokens3-8 tool calls/task~$350
OpenClaw~1,500 tokens2-5 tool calls/task~$280
Cursor Agent~2,000 tokens5-15 tool calls/task~$450

Consider a concrete scenario: a developer performing 5,000 code review tasks per month using GPT-5.6 Terra. Each task processes 5,000 tokens of code and generates 1,500 tokens of review.

  • Raw API: (5,000 × $2.50/1M + 1,500 × $15.00/1M) × 5,000 = $62.50 + $112.50 = $175/month
  • Claude Code: Same token consumption + 1,200 system prompt overhead + 3 tool calls at ~800 tokens each = 8,600 tokens input + tool responses. Cost: (8,600 × $2.50/1M + 1,500 × $15.00/1M) × 5,000 = $107.50 + $112.50 = $220/month (26% premium)
  • Cursor Agent: 2,000 system prompt + 8 tool calls at ~1,000 tokens each = 15,000 tokens input. Cost: (15,000 × $2.50/1M + 1,500 × $15.00/1M) × 5,000 = $187.50 + $112.50 = $300/month (71% premium)

The premium is not wasted — it pays for features like MCP server integration, file system awareness, and autonomous debugging. But it must be budgeted for.

Cost Optimization Strategies

Model routing is the highest-leverage optimization. Instead of using one model for all tasks, route simple queries to budget models and complex queries to frontier models. A two-tier system where 80% of requests hit DeepSeek V4 Flash ($0.14/$0.28) and 20% hit GPT-5.6 Sol ($5.00/$30.00) costs roughly 3% of an all-Sol approach for the same task volume[deepseek-pricing].

Prompt caching reduces input costs by 90% on cached prefixes. If your application uses a system prompt that is identical across requests, configure the cache and reuse the same prefix. GPT-5.6 charges $0.50/M for cached input instead of $5.00/M for Sol, and Claude charges $0.50/M instead of $5.00/M for Opus 5[anthropic-cache].

Batch processing offers 50% discounts at OpenAI for non-real-time workloads. Submit a batch of requests and receive results within 24 hours at half the price[openai-batch]. For nightly data processing, report generation, or bulk content analysis, batch APIs cut costs dramatically.

Agent turn minimization is specific to agentic workloads. Each unnecessary tool call costs money. Profile your agent's behavior and remove redundant or low-value tool invocations. If an agent calls a web search tool before checking whether the answer is already in context, that is a wasted turn.

Monitor environmental overhead. If you use OpenCode or Cursor, measure the actual system prompt overhead by comparing token counts in the API dashboard vs your estimated content token count. Environmental overhead runs 500-3,000 tokens per conversation and is invisible to the user but visible on your bill.

Rate Limits and Cost Implications

Rate limits impose a ceiling on token throughput that directly affects cost projections for production workloads. A model may have the per-token price you calculated, but if your application exceeds the provider's rate limit, requests are throttled or rejected, forcing retries that increase effective cost[openai-pricing].

Each provider enforces rate limits differently. OpenAI's GPT-5.6 Sol permits approximately 300 requests per minute (RPM) with a 20,000 token-per-minute (TPM) ceiling for input tokens. Anthropic's Claude Opus 5 allows 50 requests per minute with a 50,000 TPM limit on the same tier. Gemini 3.6 Flash scales more generously at 500 RPM but applies a strict 8,192 token output limit per request. DeepSeek V4 Flash offers 100 RPM with no per-request output limit, making it the most permissive for long document generation[deepseek-pricing].

The practical consequence is that achieving high throughput requires either multiple API keys with round-robin routing or a model with generous rate limits. For a customer-facing chatbot generating 10,000 requests per day, GPT-5.6 Luna at $0.20/$1.20 per million tokens may be the better choice over Opus 5 at $5/$25 not because the per-token cost is lower — though it is — but because the rate limit is higher and the cost of rate-limit-induced retries is zero.

Rate limits also affect cache performance. A high-traffic prompt that would benefit from caching sees diminishing returns if the cache is invalidated frequently. Conversely, a system prompt shared across many requests becomes cheaper with each reuse because the cached prefix cost is a fraction of the full input cost[anthropic-cache].

Hidden Costs: Embeddings and Fine-Tuning

Beyond per-token API calls, two categories of hidden costs affect LLM budgets: embeddings and fine-tuning. Embedding models convert text into numerical vectors for vector search or classification. OpenAI's text-embedding-3-large charges $0.13 per million tokens. A 10,000-document knowledge base with 500 tokens per document costs approximately $0.65 to embed — negligible once, but embeddings must be regenerated when the embedding model updates or when documents change[openai-pricing].

Fine-tuning costs break into training and inference. Training GPT-5.6 Terra on 10,000 examples averages $8 per 1,000 tokens of training data. Inference on a fine-tuned model costs the same per-token rate as the base model. The budget impact depends on how often the model is re-fine-tuned: monthly fine-tuning at $200 adds $2,400 annually to a project budget that may otherwise only see API consumption costs.

Limitations

  • No multi-provider discounts: The calculator assumes list prices. Enterprise agreements, reserved capacity, and volume discounts are not included.
  • No batch pricing modeling: Batch API discounts of 50% at OpenAI are not reflected in the per-request estimates. Use batch for non-real-time workloads.
  • Reasoning multiplier is averaged: Deep reasoning models may produce 2-4x the output cost of their stated per-token rate due to internal chain-of-thought. The agentic multiplier is an approximation.
  • Tool overhead varies: MCP server response sizes vary dramatically by tool and provider. A file read returns 10 tokens; a database query returns 10,000. The model assumes average tool response sizes.
  • No caching benefit in base estimates: Prompt caching discounts of 90% apply only to cached prefixes. First-time requests pay full price. The calculator models full-price requests.
  • No self-hosting: Models like DeepSeek V4 are open-weight and can be self-hosted to eliminate per-token costs entirely. Capital expenditure and operational costs are not compared here.

Frequently Asked Questions

Which model is cheapest for high-volume classification tasks?
DeepSeek V4 Flash at $0.14/$0.28 per million tokens is the cheapest commercial option. For self-hosted scenarios, any open-weight model eliminates per-token costs entirely but incurs infrastructure expenses.
How does agentic loop overhead change cost estimates?
Each agent turn consumes tokens independently. A 5-turn agentic task costs roughly 5x a single chat completion plus tool response tokens. Plan for 3-10x multiplier when migrating from chat to agentic workflows.
Is prompt caching worth configuring?
Yes. If your system prompt is identical across requests, caching reduces input costs by 90% on applicable models. For a 500-token system prompt across 10K daily requests on GPT-5.6 Sol, caching saves $22.50/day in input costs.
Should I use the same model in raw API vs an agent environment?
Only if you isolate the model costs from environmental overhead. Claude Code injects ~1,200 tokens of system prompt. OpenCode injects ~1,800. These overheads are billed at the same per-token rate and must be included in budget calculations.
How do batch APIs affect cost?
OpenAI's Batch API offers 50% discount with 24-hour turnaround. For non-real-time workloads like nightly data processing, batch can halve your costs. Other providers offer similar discounts at lower percentages.
What is the most overlooked cost factor?
Reasoning chain output. Frontier models generate extensive chain-of-thought before responding, sometimes 2-4x the visible output. This hidden output is billed at full output rates and is invisible to users.
How do I budget for agentic AI in production?
Start with chat completion costs for your expected token volume, then multiply by 3-5x for agent loop overhead. Add 15-20% for retries and failures. Monitor actual vs estimated and adjust monthly.
Does the calculator account for multi-turn MCP interactions?
No. MCP tool responses consume input tokens that vary by tool and dataset. A vector search returning 10 results consumes different tokens than a SQL query returning a full table. The calculator models a single request-response cycle.

References

  1. [1]OpenAI. (2026). API Pricing — GPT-5.6 Sol, Terra, Luna per-million-token rates.
  2. [2]Anthropic. (2026). Claude API Pricing — Opus 5, Sonnet 5, Haiku 4.5.
  3. [3]Google. (2026). Gemini API Pricing — Flash 3.6 and 2.5 Pro rates.
  4. [4]DeepSeek. (2026). V4 Pro and V4 Flash API Pricing.
  5. [5]OpenAI. (2026). Batch API — 50% discount for asynchronous processing.
  6. [6]Anthropic. (2026). Prompt Caching Documentation.

Last updated: August 2, 2026

1b

UnByte — Independent Software Engineering

Every calculator references authoritative sources — Editorial policy