· 13 min read · Nadeera Silva
LLM API Pricing Compared: Cost per Task, Not per Token
OpenAI, Claude, Gemini and DeepSeek API prices from their own pages, and a simple way to work out what one completed AI task really costs.

If you are adding an AI feature to a product, the first number you look up is LLM API pricing: dollars per million input and output tokens. That number matters, but it is not what ends up on your invoice. What you pay for is a finished job: a support answer that resolved the ticket, an invoice that was parsed correctly, a summary the user kept. In this post I compare current OpenAI API pricing, Claude API pricing, Gemini API pricing and DeepSeek API pricing from each provider's own pricing page, then show how I turn those per-token rates into a cost per completed task, with a small TypeScript calculator you can adapt.
Why price per token is the wrong unit
A per-token price hides four things that decide your real bill:
- How many tokens a task needs. A chatbot answer might be two model calls (one tool call, one final reply), each carrying a system prompt, tool definitions and retrieved documents. That can easily be 7,000 input tokens per call before the user has typed much.
- Output and thinking tokens. Output costs several times more than input on every provider below, and reasoning models bill their thinking as output. Google's table says so directly: "output price (including thinking tokens)".
- Tokenizers differ. The same text is not the same token count everywhere. Anthropic notes that Claude 4.7 and later models use a newer tokenizer that produces roughly 30% more tokens for the same text than earlier Claude models. So a lower sticker price can still lose on a real prompt.
- Failures still cost money. A response that fails validation, times out or needs a retry was billed. If 8% of attempts fail, every successful task carries the cost of those failures.
That is why I compare models on cost per completed task, measured on my own prompts.
OpenAI API pricing
OpenAI's pricing page lists its current flagship family at these standard rates (short context, up to 272K input tokens):
- gpt-6-astra: $10 input, $50 output, $1.00 cached input.
- gpt-6-sol: $2 input, $10 output, $0.20 cached input. gpt-6.1-sol has the same input and output price with cached input at $0.10.
- gpt-6-luna: $0.10 input, $0.50 output, $0.01 cached input.
Prompts over 272K tokens are billed at a higher long-context rate. The newest models also list a price for writing to the cache (for gpt-6-sol, $2.50 for a 30-minute write and $5.00 for a 12-hour write), so caching is cheap to read but not free to set up. The Batch and Flex tiers are half the standard price, and a Fast tier costs double. Regional data residency endpoints add 10% for models released on or after 5 March 2026.
Claude API pricing (Anthropic)
Anthropic prices each model with separate rates for base input, cache writes, cache hits and output:
- Claude Opus 5.5: $4 input, $20 output. Cache hits are $0.20 (0.05x input), and a 5-minute cache write is $5.
- Claude Sonnet 5.5: $2 input, $10 output, $0.10 cache hits, $2.50 for a 5-minute cache write.
- Claude Haiku 5.5: $0.10 input and $0.50 output for prompts up to 100,000 tokens. Over that, the whole request moves to $0.50 input and $2.50 output.
- Claude Fable 5.1: $10 input, $50 output, with cache hits at $0.25.
So how is Claude API pricing calculated? Each request is the sum of uncached input, cache writes (1.25x input for 5 minutes, 2x for 1 hour), cache reads and output, each at its own rate. The Batch API halves input and output prices, and the docs confirm batch and caching discounts stack. US-only inference through inference_geo: "us" adds a 1.1x multiplier on Claude 4.6 and later models.
Gemini API pricing (Google)
Google's page has a Free tier and a Paid tier, and two of the headline models are on introductory prices right now:
- gemini-4-argon (flagship reasoning model, paid tier only): $2 input and $10 output through 30 November 2026, rising to $4 and $20 from 1 December 2026. Context caching is implicit only, at $0.10 per million tokens until the same date.
- gemini-3.8-flash: $0.75 input and $3.75 output through 31 December 2026, then $1.50 and $7.50 from 1 January 2027. Cached input is $0.075, plus an hourly storage charge for explicit caches.
- gemini-3.5-flash-lite: $0.30 input, $2.50 output.
- gemini-2.5-flash-lite: $0.10 input, $0.40 output.
Batch and Flex are 50% of standard on the models that offer them.
DeepSeek API pricing
DeepSeek currently serves two API models, and its prices change with the time of day:
| DeepSeek model (version) | Input, cache hit | Input, cache miss | Output |
|---|---|---|---|
| deepseek-flash (DeepSeek-V4.1-Flash-1017), peak | $0.006 | $0.30 | $1.20 |
| deepseek-flash, off-peak | $0.003 | $0.15 | $0.60 |
| deepseek-v4-pro (DeepSeek-V4-Pro-0813), peak | $0.044 | $1.32 | $3.96 |
| deepseek-v4-pro, off-peak | $0.022 | $0.66 | $1.98 |
Off-peak rates are half of peak. Peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays (excluding Chinese public holidays), which is 06:30 to 09:30 and 11:30 to 15:30 in Sri Lanka. Weekends are off-peak all day. Both models have a 1M token context window, and the API accepts the OpenAI and Anthropic request formats, so trying it is mostly a base URL change.
LLM API pricing compared side by side
Here are the models I would actually shortlist for a product feature, at standard rates per 1M tokens:
| Model | Input | Output | Cached input | Batch / off-peak |
|---|---|---|---|---|
| OpenAI gpt-6-sol | $2.00 | $10.00 | $0.20 | Batch 50% off |
| OpenAI gpt-6-luna | $0.10 | $0.50 | $0.01 | Batch 50% off |
| Claude Sonnet 5.5 | $2.00 | $10.00 | $0.10 | Batch 50% off |
| Claude Haiku 5.5 (prompts up to 100K) | $0.10 | $0.50 | $0.01 | Batch 50% off |
| Gemini 3.8 Flash (to 31 Dec 2026) | $0.75 | $3.75 | $0.075 | Batch 50% off |
| Gemini 4 Argon (to 30 Nov 2026) | $2.00 | $10.00 | $0.10 | Batch 50% off |
| DeepSeek flash (peak) | $0.30 | $1.20 | $0.006 | Off-peak 50% off |
| DeepSeek V4 Pro (peak) | $1.32 | $3.96 | $0.044 | Off-peak 50% off |
On paper, the mid-tier models from OpenAI, Anthropic and Google now share the same $2 / $10 headline. The differences show up in cache pricing, tokenizer size, how much the model thinks, and how often it gets the task right the first time.
A worked cost-per-task example (with code)
Take a common feature: a support assistant that answers a customer question using retrieved help articles, like the RAG-with-citations setup I wrote about earlier. I assume one attempt is two model calls, each sending a 3,000-token cached prefix (system prompt and tool schemas), 4,000 fresh input tokens (retrieved chunks, history and the question) and 600 output tokens. 90% of calls hit the cache, and 92% of attempts produce an answer that passes my checks.
// cost-per-task.ts: estimate what one *completed* task costs, not one request.
// Prices are USD per 1M tokens, copied from each provider's pricing page on 22 Oct 2026.
type Price = {
input: number; // uncached input
output: number; // output, including reasoning/thinking tokens
cacheRead: number; // cached input (cache hit)
cacheWrite?: number; // first write of a cached prefix; defaults to input
};
const prices: Record<string, Price> = {
"gpt-6-sol": { input: 2.0, output: 10.0, cacheRead: 0.20, cacheWrite: 2.50 },
"gpt-6-luna": { input: 0.10, output: 0.50, cacheRead: 0.01, cacheWrite: 0.125 },
"claude-sonnet-5.5": { input: 2.0, output: 10.0, cacheRead: 0.10, cacheWrite: 2.50 },
"claude-haiku-5.5": { input: 0.10, output: 0.50, cacheRead: 0.01, cacheWrite: 0.125 }, // prompts up to 100k tokens
"gemini-3.8-flash": { input: 0.75, output: 3.75, cacheRead: 0.075 }, // rate through 31 Dec 2026
"deepseek-flash": { input: 0.30, output: 1.20, cacheRead: 0.006 }, // peak-hour rate
};
type Task = {
callsPerAttempt: number; // model calls in one attempt (tool loop + final answer)
cachedPrefix: number; // system prompt + tool schemas, identical on every call
freshInput: number; // retrieved docs, history, user message per call
output: number; // output tokens per call, thinking included
cacheHitRate: number; // share of calls that hit the prompt cache (0..1)
successRate: number; // share of attempts that finish the task (0..1)
batchDiscount?: number; // 0.5 for batch/flex jobs, 0 for live traffic
};
function costPerCompletedTask(p: Price, t: Task): number {
const perM = (tokens: number, rate: number) => (tokens / 1_000_000) * rate;
const write = p.cacheWrite ?? p.input;
const prefix =
perM(t.cachedPrefix, p.cacheRead) * t.cacheHitRate +
perM(t.cachedPrefix, write) * (1 - t.cacheHitRate);
const perCall = prefix + perM(t.freshInput, p.input) + perM(t.output, p.output);
const perAttempt = perCall * t.callsPerAttempt * (1 - (t.batchDiscount ?? 0));
// Failed attempts are still billed, so spread their cost over the ones that succeed.
return perAttempt / t.successRate;
}
const supportAnswer: Task = {
callsPerAttempt: 2,
cachedPrefix: 3_000,
freshInput: 4_000,
output: 600,
cacheHitRate: 0.9,
successRate: 0.92,
};
for (const [model, price] of Object.entries(prices)) {
const usd = costPerCompletedTask(price, supportAnswer);
console.log(`${model.padEnd(18)} $${(usd * 1000).toFixed(2)} per 1,000 completed tasks`);
}Run it with npx tsx cost-per-task.ts. With these assumptions I get:
| Model | Cost per 1,000 completed tasks |
|---|---|
| gpt-6-sol | $33.24 |
| claude-sonnet-5.5 | $32.65 |
| gemini-3.8-flash | $12.34 |
| deepseek-flash (peak) | $4.40 |
| gpt-6-luna | $1.66 |
| claude-haiku-5.5 | $1.66 |

Two things stand out. First, the cached prefix is a small slice of the bill once the cache is warm, so the real levers are fresh input (how many chunks you retrieve) and output length. Second, the success rate is a multiplier on everything. A cheap model that passes 70% of attempts instead of 92% costs about 31% more per completed task than the table suggests, before you count the user who gave up.
Free LLM API options
People search for a free LLM API a lot, so here is what the providers' own pages actually offer:
- Gemini API: a Free tier with free input and output tokens on some models (gemini-3.8-flash and the Flash-Lite models are free; gemini-4-argon is not). The catch is written on the page: on the Free tier, content is used to improve Google's products. Use it for prototypes, not customer data.
- Claude API: Anthropic's FAQ says new users get a small amount of free credits to test the API. There is no ongoing free tier.
- OpenRouter: 25+ free models on its Free plan, capped at 20 requests a minute and 50 a day, rising to 1,000 a day once you have bought at least $10 of credits. Its own FAQ says these are usually not suitable for production.
- OpenAI: I did not find a free tier for chat models on the pricing page. The moderation model is listed as free.
How to cut LLM API cost without hurting quality
This is the checklist I go through before shipping an AI feature:
- Put stable content first (system prompt, tool schemas, policies) so prompt caching can reuse it, and keep per-request data at the end.
- Cap output. Set a sensible max output length and ask for structured, short answers. Output is the most expensive token on every provider here.
- Control thinking. Reasoning tokens are billed as output. Use a lower reasoning effort for simple steps.
- Retrieve less, retrieve better. Fewer, better-ranked chunks cut fresh input directly.
- Batch anything that can wait. Nightly summaries, tagging and evaluations can run on Batch or Flex at half price, or on DeepSeek off-peak hours.
- Route by difficulty. Send easy requests to a small model (gpt-6-luna, Claude Haiku 5.5, Flash-Lite) and escalate only when a check fails. This is the same "deterministic first, model when needed" idea from my post on n8n agents versus workflows.
- Validate before you retry. Check the output against a schema and retry with a cheaper model or a smaller prompt, instead of blindly repeating the same expensive call.
- Set budgets and alerts per API key, and keep keys on your server, never in the app (see how I keep API keys out of Flutter apps).
Using OpenRouter for model routing
If you want to switch models without rewriting code, OpenRouter exposes one OpenAI-compatible API in front of many providers. According to its pricing page, it bills inference at the provider's list price with no markup and charges a 5.5% fee when you buy credits on the Standard plan (the FAQ adds a $0.80 minimum). Attempts that error out are not charged for model tokens, and the openrouter/auto router adds no fee. Its :floor model variant sorts providers by price. The trade-off is that 5.5% fee, so at higher volume compare it with calling each provider directly.
Which LLM API should you pick?
For most product features I would start the comparison with one mid-tier model and one small model from two different providers, run the same 200 real tasks through each, and compare cost per completed task and pass rate. On list prices alone, the small OpenAI and Claude models are the cheapest per task in my example, DeepSeek flash comes next and gets cheaper again off-peak, Gemini 3.8 Flash sits in the middle until its January price change, and the $2 / $10 tier is where you pay for harder reasoning. The right answer is the cheapest model that passes your checks, and that can only come from measuring your own tasks.
Frequently asked questions
Which LLM API is cheapest?
On list prices checked on 22 October 2026, the lowest per-token rates are on small models: gemini-2.5-flash-lite at $0.10 input and $0.40 output per million tokens, OpenAI gpt-6-luna and Claude Haiku 5.5 at $0.10 and $0.50, and deepseek-flash off-peak at $0.15 and $0.60. The cheapest per completed task depends on how many tokens your task uses and how often the model gets it right, so measure on your own prompts.
Is there a free LLM API?
Yes, with limits. The Gemini API has a free tier on some models, but free-tier content is used to improve Google's products. OpenRouter offers 25+ free models capped at 50 requests a day, and Anthropic gives new users a small amount of free credit for testing.
How is Claude API pricing calculated?
Each request adds up uncached input tokens, cache writes, cache reads and output tokens, each at its own per-million rate. Cache writes cost 1.25x input for 5 minutes or 2x for 1 hour, cache reads are a small fraction of input, and the Batch API halves input and output prices.
Is ChatGPT Plus the same as OpenAI API pricing?
No. ChatGPT Plus is a consumer subscription for the ChatGPT app, while the OpenAI API is billed separately per token through the API platform. A Plus subscription does not include API usage.
How much does the DeepSeek API cost?
As of 22 October 2026, deepseek-flash costs $0.30 per million input tokens on a cache miss and $1.20 per million output tokens at peak, and half that off-peak. deepseek-v4-pro costs $1.32 input and $3.96 output at peak, also halved off-peak.
Does prompt caching really save money?
Yes, when a large part of every prompt is identical, such as the system prompt and tool definitions. Cache reads are billed at a small fraction of the input price, but some providers charge extra for the first cache write, so caching pays off only when the same prefix is reused within the cache lifetime.
Sources
- API pricing (OpenAI)
- Pricing (Claude API) (Anthropic)
- Gemini Developer API pricing (Google AI for Developers, 2026-10-19)
- Models & Pricing (DeepSeek API Docs)
- Your First API Call (DeepSeek API Docs)
- Pricing (OpenRouter)
- Frequently Asked Questions (OpenRouter)
- Managing billing for ChatGPT and the API platform (OpenAI Help Center)
- What is ChatGPT Plus? (OpenAI Help Center)
Keep reading
- n8n AI Agent vs Workflow: Which to Use in 2026n8n Agents are in Preview. When an n8n AI agent beats a fixed workflow for small-business automation, what it costs, and how to set one up safely.
- RAG with Citations on PostgreSQL and pgvector: How I Built ItHow I built RAG with citations on PostgreSQL and pgvector for Pactroom: schema, project-scoped retrieval, citation prompts and the HNSW filtering trap.
- MCP Stateless Update: Migrate Your Server to 2026-07-28MCP's 2026-07-28 spec drops sessions and the initialize handshake. What breaks in your MCP server, and how to migrate a TypeScript server step by step.
Comments
Share a question or note about this article.
Loading comments…