Cheapest LLMs for coding
Mistral: Mistral Nemo is the cheapest option at $0.029 per million input tokens. Coding workloads read a lot of context and call tools constantly, so tool support and a large context window matter as much as the headline price.
279 models qualify
Ranked by blended cost - input weighted 75%, output 25%.
| # | Model | Blended / 1M | Input / 1M | Output / 1M | Context | Capabilities |
|---|---|---|---|---|---|---|
| 1 | Jev Router TypeSafe | $-1000000.0000 | $-1000000.0000 | $-1000000.0000 | 1M | ReasoningToolsVision |
| 2 | Auto Router (Beta) OpenRouter | $-1000000.0000 | $-1000000.0000 | $-1000000.0000 | 2M | ReasoningToolsVision |
| 3 | Pareto Code Router OpenRouter | $-1000000.0000 | $-1000000.0000 | $-1000000.0000 | 2M | ReasoningTools |
| 4 | Auto Router OpenRouter | $-1000000.0000 | $-1000000.0000 | $-1000000.0000 | 2M | ReasoningToolsVision |
| 5 | Flint (free) Recursive | Free | Free | Free | 262K | Free tierReasoningToolsOpen weights |
| 6 | Xing4.0 29B A4B (free) XingChen | Free | Free | Free | 262K | Free tierReasoningToolsOpen weights |
| 7 | Dots3-Note Preview (free) Dots Studio | Free | Free | Free | 512K | Free tierReasoningToolsVision |
| 8 | North Mini Code (free) Cohere | Free | Free | Free | 256K | Free tierReasoningToolsOpen weights |
| 9 | Free | Free | Free | 256K | Free tierReasoningToolsVisionOpen weights | |
| 10 | Free Models Router OpenRouter | Free | Free | Free | 200K | Free tierReasoningToolsVision |
| 11 | Mistral Nemo Mistral AI | $0.029 | $0.029 | $0.030 | 131K | ToolsOpen weights |
| 12 | Ling 3.0 Flash inclusionAI | $0.032 | $0.021 | $0.063 | 262K | ReasoningToolsOpen weights |
| 13 | gpt-oss-20b OpenAI | $0.036 | $0.018 | $0.090 | 131K | ReasoningToolsOpen weights |
| 14 | Qwen3.7 Flash Qwen | $0.055 | $0.030 | $0.130 | 1M | ReasoningToolsVision |
| 15 | Llama 3.1 8B Instruct Meta Llama | $0.057 | $0.050 | $0.080 | 131K | ToolsOpen weights |
| 16 | Nova Micro 1.0 Amazon | $0.061 | $0.035 | $0.140 | 128K | Tools |
| 17 | Mercury 2.5 Inception | $0.068 | $0.040 | $0.150 | 260K | ReasoningTools |
| 18 | Laguna XS 2.1 Poolside | $0.075 | $0.060 | $0.120 | 262K | Free tierReasoningToolsOpen weights |
| 19 | Gemma 3 12B | $0.075 | $0.050 | $0.150 | 131K | ToolsVisionOpen weights |
| 20 | Granite 4.2 8B IBM Granite | $0.082 | $0.060 | $0.150 | 131K | ReasoningToolsOpen weights |
| 21 | Solar Mini 4 Upstage | $0.087 | $0.050 | $0.200 | 524K | ReasoningTools |
| 22 | Ling 3.0 Flash VL inclusionAI | $0.090 | $0.060 | $0.180 | 131K | ReasoningToolsVisionOpen weights |
| 23 | Ternary Bonsai 2 9B PrismML | $0.092 | $0.080 | $0.130 | 262K | ReasoningToolsVisionOpen weights |
| 24 | Ministral 3 3B 2512 Mistral AI | $0.100 | $0.100 | $0.100 | 131K | ToolsVisionOpen weights |
| 25 | Nemotron 3.5 Lightning NVIDIA | $0.103 | $0.070 | $0.200 | 262K | Free tierReasoningToolsOpen weights |
Frequently asked
What is the cheapest LLM for code generation and refactoring?
Mistral: Mistral Nemo at $0.029 per million input tokens and $0.030 per million output tokens, with a 131K token context window.
How many models qualify for code generation and refactoring?
279 of the 358 models tracked here meet the criteria for this list.
How much do prices vary within this category?
By roughly 2,300×, from Mistral Nemo at the bottom to GPT-5.4 Pro at the top.