Logo for tommyjepsen.com
Logo for tommyjepsen.com
Run LLM locally for coding

Run LLM locally for coding

2026-01-31 Tommy Jepsen ✌️

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

The Brain: Qwen3 Coder 30B

The Agent: OpenCode

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.

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

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

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

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.

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

Now Press on "Manage Tokens"

run-llm-locally-for-coding-with-qwen-and-opencode-08

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

opencode

then

ctrl+p

and go down to "Connect Provider"

run-llm-locally-for-coding-with-qwen-and-opencode-04

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

run-llm-locally-for-coding-with-qwen-and-opencode-05

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

5. The Workflow

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

ctrl+p -> Select Model

Make sure the model is loaded here.

run-llm-locally-for-coding-with-qwen-and-opencode-06

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.

Hey 👋

My name is Tommy. Im a Product designer and developer from Copenhagen, Denmark.

Connected with me on LinkedIn ✌️