Put Grok 4.7 next to GPT-6.1 Sol in any LLM API pricing comparison table and Grok wins. Both charge $2 per million input tokens, and Grok's output is $6 against Sol's $10. Price a typical coding-agent task on both with prompt caching on, and Sol comes to $0.88 against Grok's $1.42.

Neither the input nor the output column explains that. An agent re-reads its own context dozens of times per task, so the price that decides the bill is what a cached token costs. Of the five top non-forum Google results for this comparison, three give no per-model cached-input price and none gives a per-model price for writing a token into the cache (checked October 2026).

The short answer: a price comparison that predicts your bill prices a whole task: fresh input at the input (or cache-write) rate, cached input at the cache-read rate, output at the output rate. On a 2-million-token coding-agent task with 90% of input served from cache, GPT-6 Luna ($0.05) and DeepSeek V4.1 Flash ($0.09) are the cheapest LLM APIs here, and at the $2 tier GPT-6.1 Sol ($0.88) beats Gemini 3.1 Pro ($1.00), Claude Sonnet 5.5 ($1.06) and Grok 4.7 ($1.42). Prices checked October 2026 on each provider's own pricing page.

LLM API pricing comparison: 12 models, checked October 2026

These are list prices per million tokens, standard tier (no batch discount). The two columns on the right are the ones that matter for agents.

ModelInputOutputCache writeCache read (× input)Watch for
Claude Fable 5.1$10.00$50.00$12.50$0.25 (0.025×)Flat rate across the 1M window
Claude Opus 5.5$4.00$20.00$5.00$0.20 (0.05×)Flat rate across the 1M window
Claude Sonnet 5.5$2.00$10.00$2.50$0.20 (0.1×)Flat rate across the 1M window
GPT-6 Astra$10.00$50.00$12.50$1.00 (0.1×)2× input, 1.5× output above 272K
GPT-6.1 Sol$2.00$10.00$2.50$0.10 (0.05×)2× input, 1.5× output above 272K
GPT-6 Luna$0.10$0.50$0.125$0.01 (0.1×)2× input, 1.5× output above 272K
Gemini 3.1 Pro (preview)$2.00$12.00none (implicit)$0.20 (0.1×)$4 / $18 for prompts over 200K
Gemini 3.8 Flash$0.75$3.75none (implicit)$0.075 (0.1×)Doubles to $1.50 / $7.50 on 2027-01-01
Grok 4.7$2.00$6.00none$0.50 (0.25×)Whole request doubles at 200K prompt tokens
DeepSeek V4.1 Flash$0.30$1.20none$0.006 (0.02×)Half price outside weekday peak hours
GLM-5.3$1.40$4.40none$0.26 (0.19×)—
Kimi K2.7 Code$0.95$4.00none$0.19 (0.2×)262K context window

Sources, all checked on 2026-10-02: Anthropic pricing, OpenAI pricing and its prompt caching guide, Gemini API pricing, DeepSeek pricing, the Grok 4.7 model page and xAI caching pricing, Z.ai pricing and Kimi pricing. DeepSeek's listed rate is its peak rate, which applies on weekdays (Chinese public holidays excepted) between 01:00 and 04:00 UTC and between 06:00 and 10:00 UTC; every other hour bills half.

"Cache write" is what a token costs the first time it's stored. Anthropic charges 1.25× input for a 5-minute entry (2× for one hour). OpenAI charges 1.25× on GPT-5.6 and later. Gemini, Grok, DeepSeek, GLM and Kimi K2.7 bill uncached tokens at the plain input price. How caching works, and what silently breaks it, is covered in prompt caching explained.

Look at the read column before the input column. Inside the $2 input tier, a cached token costs $0.10 on GPT-6.1 Sol, $0.20 on Sonnet 5.5 and Gemini 3.1 Pro, and $0.50 on Grok 4.7. That 5× spread is invisible in any AI pricing comparison that lists only input and output.

Every row matches the list price in our model catalog (snapshot 2026-10-02). Disclosure: Octomind is ours, and through the Octomind hub each of these models bills at the provider's price plus 5%, cache reads and writes included.

How many tokens does one agent task use?

Far more than a chat: on our public coding benchmark, one task consumed 0.7 to 3.5 million input tokens depending on the agent, and 92–98% of it came from cache. These are the per-task averages from five runs recorded in octobench's BENCHMARK.md at commit 9aaf2fe (results dated 2026-08-26), each over 50 or 80 tasks taken from real merged pull requests:

Agent + modelInput per taskServed from cacheOutput + reasoning per taskCost per taskTasks passedCost per passed task
Claude Code + Claude Opus 53.31M98.1%23.8K$3.1773/80$3.47
Codex + GPT-5.6 Sol0.69M92.5%4.8K$0.7271/80$0.81
Codex + GPT-5.6 Luna1.26M94.3%6.9K$0.0567/80$0.06
Octomind + GLM-5.33.52M95.9%74.0K$1.4046/50$1.53
opencode + GLM-5.33.33M98.2%27.3K$1.0643/50$1.23

I computed the per-task columns from the run totals in that file. Three things carry over to any agent workload. Input dwarfs output: output plus reasoning ran 0.5% to 2.1% of input. Nearly all input is cached: every run served more than nine input tokens in ten from cache. And the agent decides the volume: Codex used 0.69M–1.26M tokens per task on the two GPT-5.6 models, while Claude Code, Octomind and opencode used 3.3M–3.5M on theirs.

For the rest of this article I use a round reference task from the middle of that range: 2,000,000 input tokens and 20,000 output tokens. Opus 5 and both GPT-5.6 models have since been superseded in our catalog by cheaper successors, so treat the dollar columns above as measured history and the token columns as the profile.

How to compare LLM API costs: the per-task formula

Price the task, not the token. For one task:

text
cost = ( I × (1 − h) × W  +  I × h × R  +  O × P ) / 1,000,000

I = input tokens summed over every model call in the task (cached included)
h = share of I served from cache (0 to 1)
W = cache-write rate, or the input rate if the provider has no write charge
R = cache-read rate
O = output tokens, reasoning included
P = output rate

On a cached run, almost every fresh token in an agent loop is written once and read on later turns, so the formula bills all of I × (1 − h) at the write rate. At h = 0 nothing is written and fresh input bills at the input rate.

python
def cost_per_task(input_tokens, output_tokens, hit, p_in, p_out, p_read, p_write=None):
    """Prices in $ per 1M tokens. hit = share of input served from cache, 0 to 1."""
    fresh = input_tokens * (1 - hit)
    fresh_rate = p_write if hit and p_write else p_in
    return (fresh * fresh_rate + input_tokens * hit * p_read + output_tokens * p_out) / 1e6

# Claude Sonnet 5.5, 2M input / 20K output, 90% of input from cache
print(round(cost_per_task(2_000_000, 20_000, 0.9, p_in=2.00, p_out=10.00, p_read=0.20, p_write=2.50), 2))
# Grok 4.7, same task (no separate cache-write price)
print(round(cost_per_task(2_000_000, 20_000, 0.9, p_in=2.00, p_out=6.00, p_read=0.50), 2))

Expected output with Python 3.14:

text
1.06
1.42

Cost per task at 0% and 90% cache: the ranking changes

With caching counted, Grok 4.7 falls from sixth to ninth and GPT-6.1 Sol climbs from a tie for seventh to sixth. The reference task (2M input, 20K output) on all 12 models, at list price:

ModelNo cacheRank90% from cacheRank
GPT-6 Luna$0.211$0.051
DeepSeek V4.1 Flash$0.622$0.092
Gemini 3.8 Flash$1.583$0.363
Kimi K2.7 Code$1.984$0.614
GLM-5.3$2.895$0.845
Grok 4.7$4.126$1.429
Claude Sonnet 5.5$4.207=$1.068
GPT-6.1 Sol$4.207=$0.886
Gemini 3.1 Pro$4.249$1.007
Claude Opus 5.5$8.4010$1.7610
Claude Fable 5.1$21.0011=$3.9511
GPT-6 Astra$21.0011=$5.3012

Four readings:

Grok 4.7 is the cheapest $2 model only when nothing is cached. Its $6 output saves 8 cents on this task. But Grok API pricing puts cache reads at $0.50 per million, so at 90% cache its 1.8M cached tokens cost $0.90, more than GPT-6.1 Sol's whole task. Grok fits short, output-heavy calls; for long cached agent loops it's the most expensive model in its tier.

Claude Fable 5.1 and GPT-6 Astra tie per token and split per task. Both list $10/$50 and both cost $21.00 uncached. Fable reads cache at $0.25, Astra at $1.00, so the cached task is $3.95 against $5.30: Fable is 25% cheaper.

Opus 5.5 costs 2× Sonnet 5.5 per token, and the gap shrinks as caching grows. Both read cache at $0.20, because Anthropic prices Opus 5.5 reads at 0.05× instead of 0.1×. Per task the ratio is 1.66× at 90% cache and 1.43× at 98%. If you were holding back from Opus on price alone, rerun the math at your real cache share.

At agent cache shares, the read rate is often the biggest line on the bill. At 98% cache, Sonnet 5.5's reference task costs $0.69, and $0.39 of that is cache reads. The five cheapest models keep their places either way; the reordering happens in the $2–$10 input tier.

What is the cheapest LLM API?

Per task in this comparison, GPT-6 Luna at about 5 cents with caching, then DeepSeek V4.1 Flash at 9 cents, which drops to under 5 cents if the work runs outside DeepSeek's weekday peak hours. Uncached, Luna is $0.21 and DeepSeek $0.62 (peak) or $0.31 (off-peak).

Cheap only counts if the task gets done, so look at the last column of the benchmark table. GPT-5.6 Luna, GPT-6 Luna's predecessor, passed 67 of 80 tasks at $0.06 per passed task. GPT-5.6 Sol, in the same agent, passed 71 at $0.81. The four extra passes cost $53.83 more over the run. Whether that's a bargain depends on what a failed task costs you to redo by hand.

Use the price data like this:

  • Pick GPT-6 Luna or DeepSeek V4.1 Flash for high-volume, well-specified work, and try them on everything else before paying for a bigger model. Schedule DeepSeek batch jobs for off-peak hours.
  • Pick GPT-6.1 Sol when you want a $2-tier model for long cached sessions that stay under 272K tokens of context. It has the lowest read rate in its tier.
  • Pick Claude Sonnet 5.5 or Opus 5.5 when calls regularly run past 200K tokens of context: Anthropic bills the whole 1M window at standard rates, while Gemini 3.1 Pro (above 200K) and Grok 4.7 (from 200K) step up, and OpenAI's long-context price starts above 272K input tokens.
  • Pick Grok 4.7 for short calls where output dominates, not for long agent loops.

The model catalog lists the rest of the roster with the same input and output prices if your shortlist isn't in this table.

Five things that move cost per task more than the price list

1. Whether your route caches at all. In our real-PR benchmark, GLM-5.2 ran through Ollama's cloud with no prompt caching, so every turn paid full price for its whole context again. Price the reference task that way on GLM-5.3 and it costs $2.89, against $0.84 cached and $0.88 for GPT-6.1 Sol cached: the model that's cheaper per token is 3.3× more expensive per task. Fix: after the second call of a session, check the cached-token field. If it reads zero, change the endpoint or move whatever is changing out of the front of your prompt.

2. The agent's token volume. In the July run of that benchmark, on the same model, endpoint and prices, opencode pushed 30M input tokens through one task where Octomind needed 8M. Across the five runs above, input per task ranged from 0.69M to 3.52M. On Sonnet 5.5 at 90% cache with the same 20K output, that's $0.50 versus $1.71 for one task. Fix: measure tokens per task in your agent before you switch models; the harness can move the bill more than the model.

3. Context-length tiers. OpenAI charges 2× input and 1.5× output once a request passes 272K input tokens. Gemini 3.1 Pro steps up past 200K. Grok 4.7 bills the whole request, cached tokens included, at double once the prompt reaches 200K. If every call of the reference task ran above the line, GPT-6.1 Sol would cost $1.66 and Grok 4.7 $2.84. Fix: compact context before the threshold, or run long sessions on a model with a flat rate across its window.

4. The tokenizer. A per-token price is per that vendor's token. Anthropic's pricing page says Claude 4.7 and later models use a tokenizer that produces about 30% more tokens for the same text than its previous one. If you sized a Sonnet 5.5 task with Anthropic's older tokenizer and the real count runs 30% higher, the reference task goes from $1.06 to $1.38. Fix: compare models on tokens measured from the same task, never on tokens estimated from text length.

5. The calendar. DeepSeek halves its prices outside weekday peak hours. Gemini 3.8 Flash's $0.75/$3.75 runs "through December 31, 2026", then doubles, taking the cached reference task from $0.36 to $0.72. OpenAI says GPT-5.6 Sol's promotional price lasts "at least through November 21, 2026." Fix: put an expiry date next to every price in your cost model.

How to get your own token profile

Run three to five representative tasks and read the usage fields the API returns. Don't estimate from text length.

  • Anthropic API: total input is cache_read_input_tokens + cache_creation_input_tokens + input_tokens, per the Anthropic prompt caching docs.
  • OpenAI API: usage.input_tokens includes cached tokens. usage.input_tokens_details.cached_tokens and cache_write_tokens split it, per the OpenAI prompt caching guide.
  • Gemini API: cache hits appear in usage.total_cached_tokens (Gemini caching docs).
  • xAI API: usage.input_tokens_details.cached_tokens on the Responses API (xAI caching docs).
  • Claude Code: claude -p --output-format stream-json --verbose ends with a result event whose usage block holds the task's token counts. That's where octobench reads them (parser).
  • Codex CLI: codex exec --json prints JSONL events. Each turn.completed carries usage with input_tokens (cached included), cached_input_tokens and output_tokens, reported as running totals for the thread (parser).
  • Octomind: --format jsonl emits a cost event with input_tokens, output_tokens, cache_read_tokens, cache_write_tokens and reasoning_tokens (structured output docs).

I checked the Claude Code and Codex flags against --help on Claude Code 2.1.287 and codex-cli 0.160.0. Sum each field over the task, set I to all input including cached, h to cached divided by I, and O to output plus reasoning, then run the formula against each shortlisted model's row in the table.

Where this comparison is weak

  • List prices only. No batch discounts (Anthropic and OpenAI both take 50% off for asynchronous jobs), no negotiated rates, and no reseller or router prices, which can sit above or below the lab's own list.
  • One workload shape. The reference task is a coding agent: input-heavy and cached. A chat that sends 500 tokens and gets 300 back weighs output far more, and the cheap-output models move up.
  • 90% is an assumption. The five runs measured 92–98%, but a harness that rewrites its prompt or switches tools mid-session can get far less. Measure yours.
  • Five-minute writes. One-hour cache writes cost 2× input on Anthropic, which raises the cached columns for Claude.
  • Superseded models in the benchmark. The pass rates are for a model and agent together, on models our catalog has since replaced. They show the shape of the trade-off, not today's prices.
  • Gemini 3.1 Pro is a preview model on Google's pricing page; preview pricing can change.

Get Octomind — one login reaches every model in this table through the hub, at the provider's price plus 5%.

FAQ

What is the cheapest LLM API in October 2026?

Among the 12 models compared here, GPT-6 Luna at $0.10 input and $0.50 output per million tokens is the cheapest AI API per token and, in most cases, per task. DeepSeek V4.1 Flash ($0.30/$1.20 at peak, half that off-peak) comes close. Off-peak, its $0.003 cache-read rate makes it slightly cheaper than Luna on a cached agent task: $0.047 against $0.053 for a 2-million-token task.

How do I compare LLM API pricing for my own workload?

A useful LLM pricing comparison prices a whole task instead of a token: fresh input at the input or cache-write rate, plus cached input at the cache-read rate, plus output at the output rate. Take the token counts from the usage fields of three to five real runs, not from text length. In the five agent runs measured here, more than 90% of input came from cache, so the cache-read rate often decides the ranking.

Is Claude more expensive than GPT?

Per token, Claude Sonnet 5.5 and GPT-6.1 Sol both list $2 input and $10 output. Per cached agent task, GPT-6.1 Sol is cheaper because it reads cache at $0.10 per million tokens against Sonnet's $0.20: $0.88 versus $1.06 on a 2-million-token task. Past 272K tokens of context the order can flip, because OpenAI doubles input prices there and Anthropic doesn't.

Does prompt caching change which LLM is cheapest?

Yes. Cache-read rates run from 0.02× input (DeepSeek V4.1 Flash) to 0.25× (Grok 4.7), so two models with the same input price can differ 5× on cached tokens. In this comparison caching moved Grok 4.7 from the cheapest $2-tier model to the most expensive one, and made Claude Fable 5.1 25% cheaper than GPT-6 Astra despite identical list prices.

Why is my agent bill higher than the per-token price suggests?

Because an agent resends its whole context on every call, so one task can consume millions of input tokens even when it writes only a few thousand. On our benchmark, tasks used 0.7 to 3.5 million input tokens each. If prompt caching isn't hitting, every one of those tokens bills at the full input price instead of the cached rate, which is 2% to 25% of it on the models compared here.