Best Open Source Models for Coding (2026)
Choose a model by deployment constraint first: local hardware, license, data handling, then the coding task. “Open source” is often shorthand for open weights, which is still different from releasing the training data and code needed for full reproducibility.
How to Access These Models
The simplest way to reach any open-weights model via API is OpenRouter. It's a unified gateway that gives you access to hundreds of models from dozens of providers through a single endpoint and API key. Instead of signing up separately for Alibaba Cloud (Qwen), DeepSeek, Meta AI, and every other provider, you put one key in your client and switch models by changing a string.
For terminal agents like OpenCode, the setup is a one-line config change pointing at OpenRouter with your preferred model slug. For local use, Ollama handles model downloads and a simple local server, with most of the models below available as ollama pull <model>.
There's no OpenRouter-specific article on this site yet, but the OpenRouter documentation at openrouter.ai covers setup in detail.
Benchmark Context
Before the model picks, a word on the numbers, because a benchmark score with no context is how people end up disappointed. The one that matters most for coding is SWE-Bench Verified: a set of real GitHub issues from real open-source projects, where the model has to read the repo, write a patch, and pass the project's own test suite. A score of 70% means the model resolved 70% of those issues end to end. That's a far harder thing than completing a function from a docstring, which is what older benchmarks like HumanEval measured, and it's why the SWE-Bench numbers are lower and more honest.
The catch is that there are two ways to run it. The plain SWE-Bench number is the model working more or less on its own. The agentic number, where the model gets a scaffold that lets it run commands, read test output, and iterate, is usually higher, sometimes by ten or fifteen points. So when you see a coding score quoted, the first question is which harness produced it. A model that scores well agentically is the one you want for terminal-agent work like OpenCode, because that's exactly the loop it'll run inside. A model that scores well in the plain setting is fine for single-shot completions but may flail when you hand it a multi-step task with no guardrails. The picks below are weighted toward agentic performance, because that's what most coding workflows actually look like in 2026.
DeepSeek V4 Pro
DeepSeek V4 Pro leads open-weights coding benchmarks as of mid-2026, scoring 80.6% on SWE-Bench Verified against a field where most frontier proprietary models sit in the 58–70% range. The gap is real and it's what put DeepSeek firmly on the map.
License: MIT, which is about as permissive as you get for commercial use.
API pricing (via OpenRouter, as of mid-2026, subject to change): around $0.43–$0.87 per million tokens depending on the variant. Check openrouter.ai/deepseek/deepseek-v4-pro before building a budget around this number.
Context window: 1M tokens, which handles most codebases without chunking.
The catch: DeepSeek's cloud API routes traffic through servers in China, subject to Chinese data-residency law. Multiple governments have restricted DeepSeek from government devices for exactly this reason. If you're using DeepSeek V4 Pro via the DeepSeek cloud API directly, your prompts and code leave your network. Via OpenRouter, the routing is through OpenRouter's infrastructure. For genuine data sovereignty, self-host the weights with Ollama, which keeps inference entirely local.
DeepSeek V4 Flash is the cheaper sibling at around $0.10–$0.20 per million tokens, with strong reasoning at a fraction of the Pro cost. That makes it a good first choice for agents running high-volume workflows where cost-per-task matters more than peak quality.
GLM-5.2
Z.ai's GLM-5.2 is the open-weights model that keeps surfacing when the job is agentic, long-horizon coding rather than a single-shot patch. Independent comparisons published through July 2026 repeatedly single it out for exactly that kind of work: tasks where the model plans across many steps, runs commands, reads the output, and holds a goal over a long session. One hands-on writeup ran it in production inside Claude Code for three weeks at $72 a month and kept it as a daily driver, which is a stronger signal than any leaderboard row.
License: MIT, the same permissive terms as DeepSeek, so commercial use and fine-tuning are unrestricted.
Parameters: 753B total with 40B active per token (mixture-of-experts), so self-hosting at full precision wants serious hardware; most people will reach it through a gateway like OpenRouter rather than run it locally.
Benchmarks: 62.1% on SWE-Bench Pro and 81.0% on Terminal-Bench 2.1 as reported across those comparisons, though you should treat the exact figures as directional rather than precise. Every source that ran these models flags that the harness driving them shifts the numbers by several points, so GLM-5.2's honest standing is "top-tier for agentic coding among open weights," not a precise rung on a ladder.
Context window: 1M tokens since a mid-June 2026 update, which puts it alongside DeepSeek and Qwen for whole-repository work.
Qwen 3.7
Alibaba's Qwen series has become one of the highest-volume models on OpenRouter by token throughput, which is a real signal given that developers tend to route traffic where cost and quality balance well. The open-weight Qwen 3.7 releases are designed for agent-centric workloads and perform particularly well on multi-step coding tasks. One distinction worth getting right: the Qwen 3.7-Max flagship that tops the agentic leaderboards is proprietary and API-only, so it does not belong on a self-hosting shortlist. The open-weight 3.7 line is the one you can actually download.
License: Apache 2.0 for the open-weight Qwen 3.7 releases, commercially permissive with no MAU restrictions. The Max flagship is a hosted API product, not an open-weight release.
API pricing (via OpenRouter, mid-2026): roughly $1.25/$3.75 per million input/output tokens for the Max variant. The Flash variant comes in around $0.19 input and $1.13 output per million tokens.
Context window: 1M tokens on all Qwen 3.7 variants.
For local use: Qwen 3.6-27B fits in roughly 22GB of VRAM and currently scores 77.2% on SWE-Bench Verified, which is better than some much larger models. If you have a 64GB Mac, this is the local model I'd start with for coding work.
Kimi K2.6 / K2.7 Code
Moonshot AI's Kimi line crossed into mainstream tooling on July 1, 2026, when Kimi K2.7 Code became a selectable model in GitHub Copilot's picker, the first open-weight model Copilot has offered there. It reached Pro, Pro+, and Max plans first, and stays off by default for Business and Enterprise until an admin enables it. If you already pay for Copilot, that makes Kimi the easiest open-weight model on this page to actually try, since there's nothing to self-host.
License: a modified MIT license across the K2.x releases.
Benchmarks: around 80.2% on SWE-Bench Verified, which lands it as the number-two open-weight model on Artificial Analysis's coding index, a step behind DeepSeek V4 Pro's 80.6% and within the same tier.
Context window: 256K tokens on K2.6, up to 262K on K2.7 Code.
Kimi K3 is a watch item, not a self-hosting recommendation. Moonshot announced K3 on July 16, 2026 and said weights would arrive by July 27. That schedule is not confirmation that they have shipped, so do not plan a local stack around K3 until Moonshot confirms availability and publishes the applicable license.
Meta Llama 4
Llama 4 Scout's 10 million token context window is the largest of any open-weights model I'm aware of as of mid-2026, and that matters for certain use cases: analyzing entire repositories, working with large document collections alongside code, or long multi-turn agent sessions where compressing context is expensive.
License: Llama 4 Community License, with restrictions worth reading. Commercial products need to display "Built with Llama" branding, and there's a 700-million-monthly-active-user threshold above which you need a separate license from Meta. EU users have restrictions on multimodal capabilities.
For local use: the Scout variant runs on reasonable hardware; the Maverick behemoth requires serious GPU memory. Start with Scout unless you specifically need the larger model's capabilities.
OpenAI GPT-OSS
OpenAI shipped their first open-weights models since GPT-2 back in August 2025: gpt-oss-120b and gpt-oss-20b, both under a confirmed Apache 2.0 license. That's genuinely permissive with no commercial restrictions, which is unusual at this capability level. OpenAI's own positioning put the 120B roughly in o4-mini territory on reasoning tasks, and the 20B runs on consumer hardware. Check OpenAI's model card for current numbers before building on either.
The practical significance: Apache 2.0 means you can fine-tune it, run it commercially, and redistribute it without brand requirements. For teams building products on top of an open model, this is worth evaluating.
OLMo
If you need to meet the strict OSI definition, OLMo from the Allen Institute for AI is the one family that does. It releases model weights, training code, and the Dolma training dataset, all under Apache 2.0. Every 1,000 training steps has a checkpoint you can examine.
The honest trade: coding benchmarks aren't at DeepSeek or Qwen levels. OLMo is the right choice when genuine reproducibility or research-grade openness is the requirement, not when you need the best coding output.
Running Locally
The benchmark scores assume the cloud version of each model, full precision, no compromises. Running locally is a different conversation, and the honest answer for most laptops is "a smaller, quantized version of the model, not the one that posted the headline score." Quantization shrinks the weights to fit in less memory, and it costs you a little quality in exchange for actually fitting on your machine.
Here's the rough mapping I work from. On a 16GB laptop you're looking at 7B-class models or heavily quantized versions of something larger, which is fine for autocomplete and small edits and disappointing for anything that needs real reasoning. A 32GB machine, which is what I run, comfortably handles models up to around 13B and a quantized 27B if you're patient. At 64GB the 27B-to-34B range opens up, and that's the first tier where a local model feels close enough to a cheap cloud model that you'd actually choose it. The 70B-and-up models that genuinely rival frontier APIs want 128GB of unified memory and a current chip, which is a $6,000-plus machine, so that tier is a deliberate investment rather than something you back into.
For most people the practical local pick in mid-2026 is Qwen 3.6-27B through Ollama on a 64GB Mac. It scores well, it runs at a usable speed, and the gap to a $20 cloud subscription is small enough that the privacy and cost-control upside can justify it. Below 64GB, I'd be honest with yourself: a local model is a nice experiment and a real fallback for sensitive work, but it probably isn't replacing your daily driver yet. The full hardware breakdown, with the cost-per-tier math against subscriptions, lives in the open source vs proprietary comparison.
Choosing by Use Case
| Goal | Model | How to access |
|---|---|---|
| Best coding quality | DeepSeek V4 Pro | OpenRouter or self-host |
| Best agentic, long-horizon coding | GLM-5.2 | OpenRouter or self-host |
| Best capability per gigabyte of VRAM | Qwen 3.7 (open weights) | OpenRouter or self-host |
| Easiest to try without self-hosting | Kimi K2.7 Code | GitHub Copilot picker |
| Best long-context tasks | Llama 4 Scout | Ollama or OpenRouter |
| Best local on 64GB Mac | Qwen 3.6-27B | Ollama |
| Best local on 16GB RAM | Llama 4 Scout (quantized) or Gemma 3 12B | Ollama |
| Most permissive commercial license | OLMo or GPT-OSS (Apache 2.0) | Ollama or OpenRouter |
| Cheapest API for high volume | DeepSeek V4 Flash | OpenRouter |
| Data sovereignty (no cloud) | Any model above | Ollama (fully local) |
A Note on Benchmark Dates
The numbers in this article reflect benchmarks available through mid-2026, sourced from OpenRouter's model pages and independent benchmark aggregators. Model versions, pricing, and rankings change frequently in this space. The practical advice: use OpenRouter's model comparison page to get current benchmark scores before building a serious workflow around any specific model.
The broader trend is clear even if individual positions shift: the gap between the best open-weights models and closed frontier models has narrowed substantially over the past year, and for many coding tasks, the difference is no longer decisive on quality alone. The decision comes down to privacy requirements, operational complexity, and cost at your usage level.
Related Reading
- Open source vs proprietary AI coding tools: the hardware reality, the platform risk lesson from OpenCode, and a decision framework
- OpenCode guide: how to configure the open-source terminal agent with your own model choices
- AI coding tool comparisons: full hub with all head-to-head matchups
Updated July 2026: Moonshot announced Kimi K3 on July 16 and said weights would arrive by July 27; that does not confirm they have shipped. Z.ai’s official GLM-5.2 model card lists 753B total parameters. Treat benchmark ranks and API prices as time-stamped signals, not permanent facts.
Sources
-
[1]
Open-weight models: the July 2026 landscape(faros.ai)
-
[2]
Kimi K2.7 is now available in GitHub Copilot(github.blog)
-
[3]
China's Moonshot AI releases Kimi K3, the largest open-source model ever(venturebeat.com)
-
[4]
DeepSeek V4 Pro on OpenRouter(openrouter.ai)
-
[5]
DeepSeek V4 Flash on OpenRouter(openrouter.ai)
-
[6]
Qwen models on OpenRouter(openrouter.ai)
-
[7]
OpenRouter models index(openrouter.ai)
- [8]
-
[9]
LLM Coding Benchmark (May 2026)(akitaonrails.com)
-
[10]
Ollama documentation(docs.ollama.com)
-
[11]
OLMo 2 model family(allenai.org)
Read Next
Open and proprietary AI coding stacks compared by licence, model access, data path, operations, and local deployment.
Claude Code and OpenCode compared by model providers, credentials, permissions, billing, local deployment, and terminal workflow.
A working developer's guide to OpenCode, the open-source terminal coding agent: install and the TUI, model choice including local via Ollama, custom agents, MCP servers, configuration and permissions, autonomous overnight loops, cost, privacy, and where it's the wrong tool.