The cheapest LLM API for coding is DeepSeek V4 Flash on raw token cost, but it did not give the cleanest answer in our test. Kimi K2.7 Code followed every requirement; GPT-5.4 mini finished four times faster. The cheapest choice changes when a bad patch forces a retry.
Four cheap coding APIs on the same bug
Four current coding-capable APIs received the same TypeScript concurrency bug on July 30, 2026. The task was deliberately small but strict: repair mapLimit so it preserves output order, enforces a positive integer concurrency limit before calling user code, never exceeds that limit, and stops scheduling work after the first rejection. Each answer also had to include exactly three tests.
This is a one-task sample of instruction following, not a coding benchmark. Each direct run used one user message, no tools, an 8,000-token output cap, provider-default temperature, and manual review against the four stated requirements. Wall time includes our shared gateway and provider/network overhead.
| Model | Verified input / output per 1M | Time | Implementation | Tests | Verdict |
|---|---|---|---|---|---|
| DeepSeek V4 Flash | $0.14 / $0.28 | 59.4s | Met all four requirements in its final version | Covered the requested behaviors | Cheapest usable answer; noisy response |
| MiniMax M3 | $0.30 / $1.20 promotional | 60.7s | Order and concurrency were correct; rejection state was set one promise layer late | Three relevant tests | Near-pass on the strict stop rule |
| Kimi K2.7 Code | $0.95 / $4.00 | 64.3s | Clean scheduler with ordered results and immediate settled state | Covered order/concurrency, rejection, and invalid limits | Most complete response |
| GPT-5.4 mini | $0.75 / $4.50 | 13.6s | Correct worker-pool implementation | Three tests, but none exercised invalid limits | Fastest clean implementation; test gap |
DeepSeek V4 Flash: lowest cost, more cleanup
DeepSeek V4 Flash eventually returned a correct implementation: it preallocated the result array, assigned by input index, validated limit, and stopped workers behind a shared rejection flag. The problem was the response itself. Before the final function, it printed an abandoned implementation containing an unresolved promise path, then explained why that draft was wrong.
That is acceptable when a developer reviews every line. It is a poor fit for an agent that extracts the first code block and applies it automatically. DeepSeek is my cheap first attempt only when tests and type checking are mandatory gates.
MiniMax M3: attractive price, one concurrency edge
MiniMax M3 produced concise code and preserved order with out[i]. Its rejection flag, however, was set in the outer Promise.all catch rather than inside the worker that observed the callback failure. That extra promise reaction leaves a small, avoidable scheduling window before other workers see the stop flag.
The price is unusually good. MiniMax's official page shows a permanent 50% reduction to $0.30/M input and $1.20/M output for M3 at up to 512K input tokens. Above 512K, the discounted row rises to $0.60/$2.40.
Kimi K2.7 Code: best complete answer in this sample
Kimi K2.7 Code returned one implementation rather than a draft plus correction. It validated the limit before scheduling, maintained an indexed result array, bounded active promises, and set settled in the rejection handler. Its three tests covered the three places this function usually breaks: completion order, scheduling after failure, and invalid limits.
Kimi was the slowest response in this run and costs more per token than DeepSeek or discounted MiniMax. I would pay that difference for unattended agent work where a missed edge case is more expensive than another cent of API usage.
GPT-5.4 mini: fastest code, incomplete test selection
GPT-5.4 mini returned the fastest correct implementation at 13.6 seconds on the clarified run. Its code met the four requirements, including validating the limit before scheduling any callbacks. The three tests checked order, peak concurrency, and rejection behavior, but the model did not test its own limit validation.
The first attempt also asked for a repository path even though the complete function was in the prompt. That single miss is not a model-wide reliability score, but it reinforces the rule for coding agents: validate the artifact, not the model name.
What 100 coding calls actually cost
Token prices become easier to compare with a concrete coding workload. Assume each request sends 8,000 fresh input tokens of instructions and repository context and receives a 2,000-token patch plus explanation. At the verified rates above, 100 calls cost between $0.168 and $1.56 before caching.
| Model | Cost for 100 calls | Formula |
|---|---|---|
| DeepSeek V4 Flash | $0.168 | 100 × (0.008 × $0.14 + 0.002 × $0.28) |
| MiniMax M3 | $0.48 | 100 × (0.008 × $0.30 + 0.002 × $1.20) |
| GPT-5.4 mini | $1.50 | 100 × (0.008 × $0.75 + 0.002 × $4.50) |
| Kimi K2.7 Code | $1.56 | 100 × (0.008 × $0.95 + 0.002 × $4.00) |
One failed retry can outweigh the per-call price gap when acceptance checks are weak; a broken patch that reaches review or production costs far more than either API call.
Repository agents can reuse stable prompt and code prefixes. Official cached-input rates are $0.0028/M for DeepSeek V4 Flash, $0.06/M for MiniMax M3, $0.19/M for Kimi K2.7 Code, and $0.075/M for GPT-5.4 mini; changing files and tool traces remain fresh input.
For chat, classification, and other non-coding workloads, the capability floor is different; the broader cheapest LLM API comparison covers those standard rates separately.
"Groq and Cerebras are blazing fast for inference, but they throttle hard once you hit moderate volume." — one developer report on r/ArtificialInteligence
Treat that report as a test case, not a provider-wide finding: measure the shortlisted API with the number of concurrent workers you will run.
The cheapest pick for each coding workflow
The cheapest LLM API for coding depends on how failures are caught. DeepSeek is the lowest-cost default when every patch runs through deterministic checks; Kimi is the safer choice from this sample when the model must cover edge cases itself.
| Workflow | Pick | Why | Avoid when |
|---|---|---|---|
| Prototypes with tests and typecheck | DeepSeek V4 Flash | $0.14/$0.28 and a correct final implementation | Your automation may apply the first code block without review |
| Unattended coding-agent loops | Kimi K2.7 Code | Most complete implementation and test selection in this sample | Latency or the lowest token bill is the binding constraint |
| Interactive editor actions | GPT-5.4 mini | 13.6s, far faster than the other three in this run | You expect generated tests to cover every stated invariant |
| Large-context budget work | MiniMax M3 | $0.30/$1.20 through 512K under its permanent discount | Strict concurrency/error semantics are central to the task |
I would not use a tiny general chat model merely because its output costs $0.08/M. A cheap coding API has to produce a patch that survives the checks your workflow can run. If no automated check exists, select for the model's first-pass completeness rather than the lowest list price.
A cheap-first route beats one permanent model
A two-tier route makes the lowest token price useful without trusting it blindly. The model selection should follow the result of deterministic checks, not prompt length or a subjective confidence score.
- Send the first attempt to DeepSeek V4 Flash.
- Run the repository's formatter, type checker, unit tests, and any task-specific hidden test.
- Accept the patch when all checks pass.
- On failure, send the original task, failed patch, and concise test output to Kimi K2.7 Code; use GPT-5.4 mini instead when interactive latency matters.
- Cap escalation attempts so an agent cannot spend indefinitely on one issue.
This route preserves DeepSeek's sub-cent economics on straightforward tasks and pays the higher rate only for measured failures. A single OpenAI-compatible model layer makes the switch a model-name change rather than four separate integrations; the AIReiter LLM API directory exposes the models behind one endpoint.
FAQ
What is the cheapest LLM API for coding?
DeepSeek V4 Flash was the cheapest coding-capable API in this test at $0.14/M input and $0.28/M output. It produced a correct final implementation, but its response also contained a broken abandoned draft, so pair it with automated checks.
Is DeepSeek good enough for coding agents?
DeepSeek V4 Flash is good enough for a cheap first attempt when the agent must pass tests, type checking, and formatting before a patch is accepted. For unattended tasks without strong checks, Kimi K2.7 Code gave the more complete response in this one-task sample.
API billing or a coding subscription: which is cheaper?
Calculate monthly API cost from measured input and output tokens using the table rates, then compare that total with the subscription price, request caps, and whether API or agent access is included. Neither billing model is inherently cheaper.
The one-line routing rule
Start coding tasks on DeepSeek V4 Flash, accept only patches that pass deterministic checks, and escalate failures to Kimi K2.7 Code or latency-sensitive work to GPT-5.4 mini. The prices are verified; the quality order comes from one constrained task and should be retested on your own repository.
