How We Compare Cost and Coding Ability
An affordable LLM coding model needs enough ability for the task before its token price becomes useful. We prioritize coding-specific evidence, then check workload cost, context tiers, tool compatibility, and an available GPT Proto model page.
The following results come from Artificial Analysis. Terminal-Bench 4.0 evaluates agentic coding and terminal use; FrontierCode 2.0 evaluates software engineering in open-source repositories. Different configurations can change results, so the evaluated setting stays beside each model.
| Evaluated model |
Terminal-Bench 4.0 |
FrontierCode 2.0 |
| Claude Haiku 5.5 Max |
33% |
35% |
| GPT-6 Luna Max |
13% |
25% |
| GLM-5.3 Flash as listed |
33% |
18% |
| DeepSeek V4.1 Flash 1017 Max |
34% |
28% |
| Gemini 3.8 Flash High |
20% |
19% |
The underlying comparisons are Haiku versus Luna, DeepSeek versus GLM Flash, and Haiku versus Gemini. These percentages describe those evaluations, not your repository's expected success rate. They also do not establish GPT Proto latency or uptime.
Price estimates below hold token usage constant to expose the billing arithmetic. Actual models can use different token counts for the same prompt, especially when reasoning is enabled.
The 5 Best Affordable LLMs for Coding
1. Claude Haiku 5.5 for Bounded Coding Tasks
Claude Haiku 5.5 is our first candidate for a targeted edit with a clear acceptance test and a prompt below 100K tokens. Its coding results above make it worth evaluating before paying for a larger Claude model.
Anthropic's release announcement positions Haiku as a model for repetitive work and coding sub-tasks alongside Sonnet and Opus. That suggests a practical starting scope: fix one function, draft a test, or investigate a contained failure.
The important cost boundary is prompt length. Upstream input/output rates rise from $0.10/$0.50 to $0.50/$2.50 per million tokens above 100K prompt tokens. A large context window does not make the cheapest tier available across that entire window.

2. GPT-6 Luna for Frequent Focused Requests
GPT-6 Luna is the budget-first candidate for repeated, limited requests: explain a function, draft boilerplate, or suggest a small fix that existing tests can judge.
Its published GPT Proto catalog rate is $0.08 input and $0.40 output per million tokens. The public coding scores are lower than Haiku's, so we would make Luna earn a broader role through task-specific evaluation.
Check the integration surface when building an agent. The OpenAI model documentation specifies reasoning-enabled tool use through Responses; Chat Completions permits function calling with reasoning effort set to none. Confirm what the GPT Proto route exposes before treating model switching as a configuration-only change.

3. GLM-5.3 Flash for Budget Visual Coding
GLM-5.3 Flash belongs on the shortlist when a coding task includes a screenshot, design reference, or rendered interface. For example, a frontend assistant may need to compare a broken layout with the intended state before proposing CSS changes.
The official GLM-5.3 Flash model card documents multimodal input, open weights, and adjustable reasoning effort. Its published default effort is max. Use another setting only after checking how the hosted route supports it.
Its two coding scores differ substantially. That is a reason to test your task mix rather than treating one terminal benchmark as a universal code-editing ranking. Visual fixes also need a rendered comparison; compilation alone cannot establish that the layout is correct.

4. DeepSeek V4.1 Flash for Test Driven Coding Agents
DeepSeek Flash is worth evaluating for agents that inspect files, propose changes, receive test failures, and try again within a defined budget.
The October 17 release announcement describes improvements to coding performance, task completion speed, and output length. The independent results in our table refer specifically to V4.1 Flash 1017 at Max effort. An unversioned alias does not, by itself, prove that your platform serves that checkpoint; record the resolved version where available.
For a broader view of DeepSeek, GLM, Qwen, and Kimi, see our Chinese LLM comparison for coding. Keep the stronger candidates available when a difficult repository change exhausts the budget route.

5. Gemini 3.8 Flash for Existing Gemini Workflows
Gemini 3.8 Flash is a candidate when your application already uses Gemini or combines code with visual material. Evaluate it in that existing workflow before adding another provider-specific integration.
Google's model update documents adjustable thinking and an introductory direct-provider rate of $0.75 input/$3.75 output per million tokens through December 31, 2026. The published GPT Proto catalog snapshot is $0.90/$4.50. Those figures do not support a claim that GPT Proto is cheaper than Google's current promotion.
We would include Gemini for workflow fit, not award it a speed title from the word Flash. Measure time to a usable answer and total task duration on your prompts.

Coding LLM API Pricing Comparison
This table uses provider-direct public text rates under the stated conditions, not GPT Proto billing rates. Keeping the source and workload explicit makes the comparison reproducible.
The small request contains 10K input and 2K billed output tokens. The repository baseline contains 200K input and 20K billed output tokens. Both assume no cache hits; billed output must include reasoning tokens where applicable.
| Model and pricing condition |
Input / output per 1M tokens |
Small request |
Repository baseline |
| Haiku 5.5 at up to 100K prompt tokens |
$0.10 / $0.50 |
$0.0020 |
Use the next tier |
| Haiku 5.5 above 100K prompt tokens |
$0.50 / $2.50 |
Not applicable |
$0.1500 |
| GPT-6 Luna within its base context tier |
$0.10 / $0.50 |
$0.0020 |
$0.0300 |
| GLM-5.3 Flash at the published standard rate |
$0.15 / $0.50 |
$0.0025 |
$0.0400 |
| DeepSeek Flash at the upstream peak rate |
$0.30 / $1.20 |
$0.0054 |
$0.0840 |
| Gemini 3.8 Flash at the introductory direct rate |
$0.75 / $3.75 |
$0.0150 |
$0.2250 |
Rate evidence comes from the linked model documentation and independent comparisons above. DeepSeek's release notes confirm that off-peak token rates are half the peak rates. Luna applies higher rates to the full request above 272K input tokens. Gemini's introductory rates end in 2026. Check the applicable route and date before budgeting.
For GPT Proto access, use the live pricing panel on the linked model pages. Two clear catalog examples are Luna at $0.08/$0.40 and Haiku at $0.09/$0.45 in the low-price tier. The same small request estimates to $0.0016 and $0.0018 respectively. These are published-rate calculations, not measured charges.
For a small application making 10,000 small requests per month, the upstream Luna or low-tier Haiku example totals $20 before retries and other charges. That estimate stops being useful if the application sends a different amount of context or generates much longer outputs.
Caching needs its own calculation: add uncached input, cache reads, any cache writes or storage, and billed output. A stable repository prefix may help, but changing the prompt or missing the cache changes the savings.
Developer Simon Willison's Haiku 5.5 test provides a concrete example of different effort settings changing time and cost. It also discusses tokenizer changes. The lesson for budgeting is to measure actual usage rather than assume every model bills the same number of tokens for identical text.
Which Model Fits Your Coding Task
| Task |
Starting candidates |
Acceptance check |
| A contained code edit or bug fix |
Haiku 5.5 and Luna |
Targeted tests plus existing regression tests |
| Drafting unit tests or boilerplate |
Luna and Haiku 5.5 |
Review assertions and verify meaningful failure cases |
| A visual frontend fix |
GLM-5.3 Flash and Gemini 3.8 Flash |
Rendered comparison plus functional tests |
| A multi-step coding agent |
DeepSeek Flash and Haiku 5.5 |
Completed task, valid tool calls, retry count, and total cost |
These are starting points for evaluation. A generated test that simply repeats the model's mistaken assumption can pass while the feature remains wrong. Preserve independent acceptance cases and inspect changes to the tests themselves.
For agents that also search documents, classify requests, or perform support tasks, our affordable LLM API guide for AI agents covers the broader workload mix.
When a Premium Coding Model Is Worth It
Escalate when the task needs difficult planning, repeatedly fails meaningful tests, or requires substantial manual repair. GLM-5.3, Qwen3.8 Max, Kimi K3.1 Pro, and Claude Sonnet 5.5 can form a separate evaluation pool for that work. Their inclusion here is an upgrade path to investigate, not a claim that they always recover failed budget-model tasks.
Use cost per accepted task: total API spend across the evaluation divided by the number of changes accepted. Include spend on failed attempts. Record review time separately so a low API bill does not hide expensive developer cleanup.
For an illustrative comparison, three $0.02 attempts cost $0.06. A $0.04 attempt that finishes the same task immediately costs less overall. Your measured success rates decide whether that trade-off holds.

How to Use Budget Models Without Endless Retries
Set the acceptance check and stop rule before the first request. A practical starting policy is one initial attempt, one correction using the test failure, then escalation or human review. Adjust that policy using observed results and a task budget.
The application should record the model and checkpoint, reasoning setting, token usage, elapsed time, validation result, and total charge. The model proposes a patch; your runner executes tests; your routing logic decides what happens next.
A multi-model API simplifies access and billing. Passing tests, budget-aware routing, and automatic escalation still require verified platform features or application logic. Our guide to AI gateways for developers compares the different access and control layers.
Try an Affordable Coding Model Through GPT Proto
Open a shortlisted model page, choose Try this model, and review the current Quick Start and pricing. Prepare an API key and balance. If the panel offers Copy Markdown for AI, pass that guide to your coding assistant with the task and acceptance criteria. Keep the real key in your local environment or server secret store.
For a reproducible first exercise, fix this pagination function: pages are one-based, page and per_page are integers, values below one must raise ValueError, and the input list must remain unchanged.
Save the following as request_patch.py in a new working folder. It uses Python's standard library, requests a candidate function, checks its syntax, and saves it for review. It does not execute the returned code.
import ast
import json
import os
import time
from pathlib import Path
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
key = os.environ.get("GPTPROTO_API_KEY")
if not key:
raise SystemExit("Set GPTPROTO_API_KEY in your environment.")
source = """def paginate(items, page, per_page):
start = page * per_page
return items[start:start + per_page]
"""
task = (
"Fix paginate. Pages are one-based. page and per_page are "
"integers; raise ValueError if either is below 1. Return an "
"empty list beyond the last page. Do not mutate items. Keep "
"the signature. Return only the function, without Markdown "
"or explanations.\n\n" + source
)
payload = {
"model": os.environ.get("GPTPROTO_MODEL", "gpt-6-luna"),
"messages": [{"role": "user", "content": task}],
}
request = Request(
"https://gptproto.com/v1/chat/completions",
data=json.dumps(payload).encode("utf-8"),
headers={
"Authorization": f"Bearer {key}",
"Content-Type": "application/json",
},
method="POST",
)
started = time.perf_counter()
try:
with urlopen(request, timeout=60) as response:
result = json.load(response)
except HTTPError as exc:
raise SystemExit(f"API returned HTTP {exc.code}.") from exc
except (URLError, TimeoutError) as exc:
raise SystemExit("Request failed or timed out.") from exc
try:
code = result["choices"][0]["message"]["content"]
except (KeyError, IndexError, TypeError) as exc:
raise SystemExit("No candidate text in the API response.") from exc
if not isinstance(code, str) or not code.strip():
raise SystemExit("The response contained no Python code.")
code = code.strip()
try:
ast.parse(code)
except SyntaxError as exc:
raise SystemExit("Review the response; it is not plain Python.") from exc
Path("candidate.py").write_text(code + "\n", encoding="utf-8")
print("Saved candidate.py. Review it before running tests.")
print("Seconds:", round(time.perf_counter() - started, 2))
print("Usage:", json.dumps(result.get("usage", {})))
Save these acceptance checks as test_candidate.py:
import unittest
from candidate import paginate
class PaginationTests(unittest.TestCase):
def test_pages(self):
items = [0, 1, 2, 3, 4]
self.assertEqual(paginate(items, 1, 2), [0, 1])
self.assertEqual(paginate(items, 2, 2), [2, 3])
self.assertEqual(paginate(items, 3, 2), [4])
self.assertEqual(paginate(items, 4, 2), [])
self.assertEqual(items, [0, 1, 2, 3, 4])
def test_empty_input(self):
self.assertEqual(paginate([], 1, 2), [])
def test_invalid_values(self):
for page, per_page in [(0, 2), (-1, 2), (1, 0), (1, -1)]:
with self.subTest(page=page, per_page=per_page):
with self.assertRaises(ValueError):
paginate([0, 1], page, per_page)
if __name__ == "__main__":
unittest.main()
With the environment key configured, run python request_patch.py. Review candidate.py, then run python -m unittest -v test_candidate.py. A syntax check only establishes that Python can parse the output; the tests assess the stated behavior. This small exercise is not a repository-scale benchmark.
Repeat with another documented model ID through GPTPROTO_MODEL. Log failures as well as passes, and use returned usage together with the applicable billing rate to compare charges. A timeout or failed attempt still belongs in the evaluation record.
Choose one narrow task, keep its acceptance checks fixed, and compare two candidates. Open the Claude Haiku 5.5 API page or GPT-6 Luna API page to review current pricing and start your first coding request.