KK

Kamil Kwapisz

Tech founder, developer, AI enthusiast

Kamil Kwapisz

Kamil Kwapisz

6 min read

Free AI coding: Ollama + Opencode

Free AI coding: Ollama + Opencode

Using LLMs for programming can be expensive. Especially if you want the real productivity.

Free AI coding - the hard way

Of course there are some tips on how to spend at AI the lowest as you can:

  • Use all quota of Cursor $20/mo plan.
  • Then use available for free model in Cursor (if there’s one).
  • Then use all free quota from Antigravity.
  • If your plans hasn’t renewed yet, just paste code into free AI chats and copy-paste results into code.

You can even omit your $20 Cursor (or whatever coding tool you use) plan and keep working with free plans.

Real AI coding productivity

But if you want to be really productive you don’t want to worry about plan limitations or switching tools during work.

And in order to achieve that, you need to:

  • buy highest plans from AI tools,
  • or use API based pricing (pay as you use)
  • or use OPEN SOURCE self hosted LLM

Open source LLMs

Open Source LLMs industry is growing almost as fast as the closed source. And if we consider number of releases per month, open source is even better.

Those models are usually smaller than premium models and in most scenarios perform worse than GPTs, Claude or Gemini models. But they’re still worth using.

Especially if your AI skills are better than:

Create new ChatGPT in typescript. Make no mistakes

Self hosted models with Ollama

And when I say “open source LLM” I don’t want you to dig into weights and it’s code or even run it from scratch using hard to use libraries. There are some tools that makes running open source LLMs extremely easy on your machine:

  • Ollama
  • LM Studio

I’ll focus now on Ollama as it’s more popular at the moment.

It’s as easy as installing Ollama following official docs and pulling model you want:

ollama pull qwen3-coder:30b

Then you can just start localhost server with ollama serve to run by default on port 11434 that will allow you to chat with locally downloaded LLM.

Picking right model: Qwen3-coder

There are a lot of available models, but the one I like for coding the most is Qwen3-coder in version with ~30 billion parameters: qwen3-coder:30b . It’s coding specialized model provided by Alibaba with 19GB size and 256K long context.

And let’s be honest - it won’t be better than Claude 4.5 Opus, GPT-5.2, Gemini 3 or any other big model you use through Cursor.

But with proper prompting and decent context handling, it can be a great coding assistant, especially used with good agentic tool.

Picking agentic coding tool: Opencode

There are few free agentic coding tools that will allow you to work with self-hosted models, but Opencode was the best one for me.

It’s fully open sourced, has some nice terminal features and is not connected with any of LLM providers. It can be even installed with npm command.

When having Ollama’s server running, you can now configure Opencode to automatically use it as an LLM provider with proper model specified. You just need to create/edit config.json at:

  • Linux/MacOS: ~/.config/opencode/config.json
  • Windows: C:\Users\kamil\.config\opencode\config.json

with JSON:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "qwen3-coder:30b",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama",
      "options": {
        "baseURL": "http://127.0.0.1:11434/v1"
      },
      "models": {
        "qwen3-coder:30b": {
          "name": "qwen3-coder:30b",
          "reasoning": true,
          "tools": true
        }
      }
    }
  }
}

Just run opencode at desired folder and voilĂ . Easy as that.

Advantages of coding with free self-hosted model

No costs

When compared with Cursor/Claude Code/GeminiCLI tools like, your costs with Opencode + Ollama are zero.

Of course, you can have a quite okay computer and pay for electricity, but still you pay less than for gaming setup.

Privacy and security

This is TOP feature and advantage. I bet you hear a lot of privacy & security concerns regarding using AI. Of course there are some APIs, plans and ways to ensure security and privacy when using premium AI vendors, but the real threat is caused by unauthorized and unsupervised use of AI in companies that don’t have clear AI policy and workflows.

I heard so many stories about programmers sending critical code or users’ data to free ChatGPT plan.

Using self hosted models gives you full control over the data as everything is happening on your machine, no data is sent or received externally.

No vendor lock-in

With such setup, you no longer depend on external providers. You can easily switch model you use without the need of switching entire toolset.

Provider independence

We all remember how frequent availability problems can be. With open source model running on your machine you no longer need to worry about. Of course, you are the one to make it work in case of problems.

And what’s even more important, you will never face model’s quality dropdown, like it was for several big LLMs. The model you use won’t change unless you download a different version.

Disadvantages of coding with free self-hosted model

Hardware requirements

AI coding with open source model is free, but you need to have a pretty decent setup. The best would be to have a GPU to run the model, but for this Qwen3-coder nice CPU (i7/i9 or ryzen 7/9) will be good enough. MacBook’s M4/M5 works great here.

You should also have at least 24GB of RAM, but 32GB+ is good to have.

Worse output quality

Open source model in smaller version won’t perform as good as the top models you used before. It’s obvious and worth keeping in mind, that it is tradeoff for low price.