# Run LLM Locally for Coding: A Step-by-Step Guide (2026)

> Learn how to run an LLM locally for coding using LM Studio, OpenCode, and Qwen3 Coder 30B on your Mac. A step-by-step guide to private, offline AI development.

- **Published:** 2026-03-10
- **Author:** Tommy Jepsen
- **Canonical URL:** https://tommyjepsen.com/blog/run-llm-locally-for-coding

---


I've experimented with running LLMs locally for coding and I'm impressed with the results. I've tried different models but for my M4 Max 32GB, I got the best results with Qwen3 Coder 30B.

If you want to try it yourself, here is the stack I use:

 **The Engine:** [LM Studio](https://lmstudio.ai/)

 **The Brain:** [Qwen3 Coder 30B ](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct)

 **The Agent:** [OpenCode](https://opencode.ai)

## 1. The Engine: LM Studio

LM Studio makes it really easy to run models locally, and you can run them as an API similar to OpenAI. So it is pretty smooth salling to get going.

You can download LM Studio here: [lmstudio.ai](https://lmstudio.ai).

You need a pretty good machine to run models locally though. As said I run M4 Max with 32gb and that works but it's not super fast.

## 2. The Brain: Qwen3 Coder 30B

Released in mid-2025, **Qwen3 Coder 30B** is not the newest model out there, but it scores pretty well on the leaderboards for coding. I've tested both on creating a NodeJS backend and developing a React TypeScript frontend, and it performs pretty well on both tasks.

What you need to do to get the model in LM Studio:
1.  Open LM Studio.
2.  Click on the **Search** (magnifying glass) icon.
3.  Type `Qwen3-Coder-30B-A3B-Instruct-MLX-4bit` which is done I used.
4.  Download it.

![run-llm-locally-for-coding-with-qwen-and-opencode-01](/content/blog/run-llm-locally-for-coding/run-llm-locally-for-coding-with-qwen-and-opencode-01.png)

Now you are ready to load it up.

## 3. Serving the Model

To let other tools (like OpenCode) talk to Qwen3 Coder, you need to turn on LM Studio's Local Server(API).

1.  Click the **Developer** tab in LM Studio.
2.  Select your downloaded **Qwen3-Coder-30B-A3B-Instruct-MLX-4bit** model from the dropdown at the top right.
3.  I turned the **Context Length** all the way up to 26k tokens.
4.  Set status to "Running" to start the API.

![run-llm-locally-for-coding-with-qwen-and-opencode-02](/content/blog/run-llm-locally-for-coding/run-llm-locally-for-coding-with-qwen-and-opencode-02.png)

You now have an API running at `http://localhost:1234/`. See if it works with:

```bash
curl http://localhost:1234/v1/models
```

## 4. The Agent: OpenCode

**OpenCode** is an open-source autonomous coding agent that lives in your terminal - similar to Claude Code.  

You can install OpenCode via Homebrew (macOS) or using their install script.

```bash
brew install opencode
```

After installing, you need to configure it to use LM Studio.

**Configuration:**

You need to create an API key in LM Studio.

Go to the Developer tab, press on Server Settings.

![run-llm-locally-for-coding-with-qwen-and-opencode-07](/content/blog/run-llm-locally-for-coding/run-llm-locally-for-coding-with-qwen-and-opencode-07.png)

Now Press on "Manage Tokens"

![run-llm-locally-for-coding-with-qwen-and-opencode-08](/content/blog/run-llm-locally-for-coding/run-llm-locally-for-coding-with-qwen-and-opencode-08.png)

Create a new token and save it.

Now we need to tell Opencode to ignore cloud providers and look at your local LM Studio server instead. Open your Terminal and run 

```bash
opencode
```

then 

```bash
ctrl+p
```

and go down to "Connect Provider"

![run-llm-locally-for-coding-with-qwen-and-opencode-04](/content/blog/run-llm-locally-for-coding/run-llm-locally-for-coding-with-qwen-and-opencode-04.png)

Now choose LM Studio and enter the API Key we generated earlier.

![run-llm-locally-for-coding-with-qwen-and-opencode-05](/content/blog/run-llm-locally-for-coding/run-llm-locally-for-coding-with-qwen-and-opencode-05.png)

That's it. It should use your local LLM now.


## 5. The Workflow

When selecting models in Opencode you can choose between different models. 

```bash
ctrl+p -> Select Model
```

Make sure the model is loaded here.

![run-llm-locally-for-coding-with-qwen-and-opencode-06](/content/blog/run-llm-locally-for-coding/run-llm-locally-for-coding-with-qwen-and-opencode-06.png)

OpenCode will now query your local Qwen3 model and do the development for you - again similar to Claude Code.

### Conclusion

It's pretty cool to run these models "for free" locally. The performance is of course not the same as running Claude Code with Opus 4.5, but if you are on a plane, or can't afford the subscription, it's a pretty good alternative.

<iframe width="560" height="315" src="https://www.youtube.com/embed/7mAPaRbsjTU?si=8M9SzK66cKAE9V3w" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>