- AI agents
- open source
- web development
Run Qwen locally for free and use it in VS Code
How to run Qwen3-Coder on your own computer with Ollama, turn it into an agent with Qwen Code and use it in VS Code, with no cloud model involved.

In this article
Cloud coding agents are convenient. But they come with two costs: every request is paid for, and every request sends your code to someone else's server.
There is another way: run the model on your own computer.
Qwen3-Coder is an open-source model built for writing code. With Ollama you run it locally, with Qwen Code it becomes an agent that reads and edits your project files, and with the VS Code extension it works right inside your editor.
This guide walks through every step, from installation to the first change in your code.
How the pieces fit together
Four tools, each with one job:
Qwen3-Coder
the model that reasons
↓
Ollama
runs it on your computer
↓
Qwen Code
turns it into an agent
↓
VS Code
shows you the changes to approve01. Run Qwen on your machine
Ollama is a free program that downloads models and runs them locally, on Windows, macOS and Linux. You can install it from ollama.com/download.
Then, from the terminal, download the model:
ollama pull qwen3-coder:30bThe download is about 19 GB. Once it is done, you can talk to it right away:
ollama run qwen3-coder:30bA chat opens in the terminal. Ask a programming question to check it works, then type /bye to exit. The model stays available in the background.
02. Choose the right model for your computer
The more parameters a model has, the more memory it needs.
Qwen3-Coder 30B uses a "mixture of experts" architecture: it has 30 billion parameters in total, but activates only about 3.3 billion for each word. That is why it is fast for its size. All the parameters still have to fit in memory, though.
The main options:
- qwen3-coder:30b: about 19 GB. It needs a 24 GB graphics card or a Mac with 32 GB of unified memory.
- qwen2.5-coder:14b: about 9 GB. Fine with a 16 GB graphics card.
- qwen2.5-coder:7b: about 4.7 GB. Runs even with 8 GB of video memory.
- qwen3-coder:480b: about 290 GB. Not meant for a regular computer: it needs a server with many graphics cards.
On top of the download size you need memory for the context, the text the model keeps in mind while it works.
If your computer cannot handle the 30B, start with a smaller model. It works with the same commands, but expect less reliable results on long tasks.
03. Give the model enough context
This is the step almost everyone skips, and it is the one that makes an agent actually work.
Ollama sets the context based on your graphics card's memory: under 24 GB it starts at 4,000 tokens, between 24 and 48 GB at 32,000. For a coding agent, which needs to read several files at once, the Ollama documentation recommends at least 64,000 tokens.
The simplest way is the context length slider in the Ollama app settings. From the terminal, on macOS and Linux, you can start the server like this:
OLLAMA_CONTEXT_LENGTH=64000 ollama serveTo check the result:
ollama psThe CONTEXT column shows the allocated context, and the PROCESSOR column tells you whether the model runs fully on the graphics card or partly on the CPU. More context means more memory: if the model spills onto the CPU, it slows down a lot.
04. Turn Qwen into a coding agent
On its own, the model answers questions. To work on a project it has to read files, edit them and run commands. That is what Qwen Code does: an open-source agent that runs in the terminal.
You need Node.js 22 or later. Then:
npm install -g @qwen-code/qwen-code@latestTo start it, go into your project folder and type:
qwenQwen Code asks you to approve the more sensitive actions, such as editing a file or running a command. Always read what it is about to do before saying yes.
05. Connect Qwen Code to your local model
Ollama exposes its models through an OpenAI-compatible API at http://localhost:11434/v1. Qwen Code can use it as a custom provider.
The configuration goes in ~/.qwen/settings.json (on Windows, in the .qwen folder inside your user profile):
{
"env": { "OLLAMA_API_KEY": "ollama" },
"modelProviders": {
"openai": [
{
"id": "qwen3-coder:30b",
"name": "Qwen3-Coder 30B (Ollama)",
"envKey": "OLLAMA_API_KEY",
"baseUrl": "http://localhost:11434/v1",
"generationConfig": { "contextWindowSize": 64000 }
}
]
},
"security": { "auth": { "selectedType": "openai" } },
"model": { "name": "qwen3-coder:30b" }
}Three details:
- The API key: Qwen Code requires one, but Ollama ignores it. Any value works, such as
ollama. - The model name: it must match what you see with
ollama list. - The context: keep it in line with what you set in Ollama.
Alternatively, on first launch you can choose "Custom Provider" and enter the same details by hand. The /auth command lets you change the configuration at any time.
If Qwen Code cannot connect to Ollama while the terminal can, check your Node.js version: an issue has been reported with Node.js 26, and the workaround is to use version 24.
06. Code with Qwen inside VS Code
Qwen Code has a VS Code extension, Qwen Code Companion. To install it:
- open the project in VS Code, with a single folder in the workspace;
- open the integrated terminal and run
qwenfrom the project root; - type
/ide installand confirm; - open a new terminal, run
qwenagain and type/ide enable.
From then on, the agent sees your recently opened files, the cursor position and the selected text. Proposed changes open in VS Code's diff viewer: you can edit, accept or reject them before they touch the file.
Select the code
↓
Ask Qwen what to do
↓
Qwen proposes the change
↓
Review it in the diff
↓
Accept or rejectWhat to expect
A local model has clear advantages:
- cost: no subscription and no per-token fees, just the hardware you already own;
- privacy: requests to the model stay on your computer;
- availability: it works even offline.
And equally clear limits:
- speed: it depends on your graphics card, and on a laptop it can be slow;
- quality: on complex tasks it stays below the best cloud models;
- memory: model and context take up most of your video memory while you work.
It works well for explaining code, writing tests, focused refactoring and working on projects you do not want to leave your machine.
Checklist before you start
Before running the first command, check at least these five points:
- Your computer has enough memory for the chosen model, plus the context.
- Ollama is installed and
ollama runresponds. - The context is at least 64,000 tokens and
ollama psconfirms it. - Node.js is on version 22 or 24.
- The model name in
settings.jsonmatches the one inollama list.
Your AI, your machine, your code
For years, AI for programming meant only one thing: a paid cloud service, with your code traveling to external servers.
Today there is a real alternative. It does not replace the most powerful models, but it gives you an assistant that works on your project, on your computer, on your terms.
Sources
Have a project in mind?
Hash42 Labs designs and builds web apps, websites and digital products for businesses, with security built in from day one. The same principles behind this article power Manji and Muni.
