medium.com 6 min read Original Source

How to Use OpenCode for Free: A Simple Setup That Actually Works

Learn how to use OpenCode for free with Zen free models, a Gemini key, OpenRouter, or local Ollama. A simple setup that works in about 10 minutes.

I almost paid for another AI coding subscription last month. My cursor was hovering over the upgrade button when I stopped and asked a boring question: what am I actually paying for?

The answer was access to models. The agent itself, the part that reads your repo, edits files, and runs commands, is a separate thing. That is where OpenCode comes in. OpenCode’s Free (BYOK) tier costs $0 and includes the full feature set. You only pay for the model tokens you use, and there are ways to pay nothing for those either.

Here is the short answer. You can use OpenCode for free by installing it, running /connect, and picking one of the free OpenCode Zen models. If you want more headroom, add a free Gemini API key, OpenRouter free models, or a local model through Ollama. The rest of this article is the setup, the honest limits, and what I would pick.

What OpenCode Actually Is (And Why It Can Be Free)

OpenCode is an open source coding agent that runs in your terminal. It works with 75+ model providers, including Claude, GPT, Gemini, and local models through Ollama.

The confusion most people have is mixing up the tool and the models. OpenCode itself is MIT licensed and free. What you pay for is model access. So the whole game is finding free model access that is good enough to be useful.

Step 1: Install OpenCode (2 Minutes)

Pick one install method:

curl -fsSL https://opencode.ai/install | bash
npm install -g opencode-ai
brew install opencode-ai/tap/opencode
curl -fsSL https://opencode.ai/install | bash
npm install -g opencode-ai
brew install opencode-ai/tap/opencode

Check that it worked:

opencode --version
opencode --version

Then move into any project folder and launch it:

cd your-project
opencode
cd your-project
opencode

Those install commands come from a June 2026 developer guide. If a command fails, check the official docs at opencode.ai, because install steps change.

Step 2: Use the Free Zen Models (Zero Setup)

This is the fastest path and the one I recommend starting with.

When you first install OpenCode, you get access to free models through OpenCode Zen, a curated set of models the OpenCode team has tested with the tool. You do not need a credit card to try them.

Inside OpenCode, type:

/models
/models

Pick a model that is marked free. If it asks you to authenticate, run:

/connect
/connect

Choose OpenCode Zen, then paste your API key from the Zen page on opencode.ai.

As of today, the Zen docs list Big Pickle, DeepSeek V4 Flash Free, MiMo V2.5 Free, and Nemotron 3 Ultra Free at zero cost. Models are referenced in the format opencode/<model-id>.

The catch you need to know about

Free here has conditions, and I would rather you hear them from me.

  • The list rotates. Several of these models are labeled as available for a limited time. The model you love this month may be gone next month.
  • Your prompts may be used for training. During free periods, your prompts may help train these models. Do not paste secrets, client code, or anything under NDA into a free model.
  • They are not frontier models. Open source alternatives are faster and cheaper, sometimes free, but they do not match the top models on difficult tasks.

For learning, side projects, scripts, and refactoring practice, that tradeoff is fine.

Step 3: Add a Free Gemini API Key (More Headroom)

If the Zen models feel too slow or too limited, Google’s free tier is the next lever.

  1. Go to aistudio.google.com and create an API key.
  2. Run /connect in OpenCode and choose Google.
  3. Paste the key.
  4. Run /models and select a Gemini model.

One guide describes this as needing no card, and estimates roughly 1,500 Flash requests per day, with per minute rate limits. Treat that number as a ballpark. Google changes free limits often, so check your AI Studio dashboard for the real figures.

Step 4: Try OpenRouter Free Models (The Variety Pack)

OpenRouter is a marketplace of models from many labs. More than 28 of them are marked free, with names ending in :free. The same source notes a daily cap that is low by default and rises once you add a small one time credit.

The setup is the same pattern. Create an OpenRouter key, run /connect, choose OpenRouter, and paste it. Then search :free in the model picker.

The benefit is choice. The downside is that free models on shared infrastructure can be slow or rate limited at busy times.

Step 5: Go Fully Local With Ollama (Truly Unlimited)

If privacy matters, or you hate rate limits, run a model on your own machine. Nothing leaves your laptop, and there is no daily cap.

Install Ollama, pull a coding model, then tell OpenCode about it in an opencode.json file in your project:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "qwen2.5-coder:7b": {
          "name": "Qwen 2.5 Coder 7B"
        }
      }
    }
  }
}
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "qwen2.5-coder:7b": {
          "name": "Qwen 2.5 Coder 7B"
        }
      }
    }
  }
}

Replace the model name with whatever you actually pulled. Restart OpenCode, run /models, and select it.

Two honest warnings. Smaller local models are noticeably weaker at multi file tasks. And your RAM decides what you can run, so a 7B model on a modest laptop is realistic, while a huge model is not.

Which Free Option Should You Pick?

My own order is simple. Start with Zen to confirm OpenCode fits your workflow. Add Gemini when you hit limits. Use Ollama for anything private.

When Free Stops Being Enough

There is a point where free models cost you time, and your time is not free. If you keep rewriting bad output, consider the paid lane.

OpenCode Go costs $5 for the first month and $10 after that, with free cancellation. It gives you a set of mostly open weight models with usage caps over a rolling window. It does not give you Claude or GPT.

Also be careful with shortcuts. One 2026 comparison warns that routing a consumer Claude or ChatGPT subscription through third party OAuth plugins is against the providers’ rules and risks your account. Use API keys instead.

A Few Habits That Make Free Models Work Better

  • Give small, specific tasks. “Add input validation to this function” beats “improve my app.”
  • Keep context tight. Open the right files and avoid dumping the whole repo.
  • Review every diff. Cheaper models make more mistakes, so never auto accept blindly.
  • Commit often. If an edit goes wrong, you can roll back in seconds.

FAQ

Is OpenCode really free?

Yes. The tool is open source and free to install. You pay only for model usage, and free options exist through Zen, Gemini’s free tier, OpenRouter, and local models.

Do I need a credit card to use OpenCode for free?

Not for the basic Zen free models in most cases, though signup requirements can change. Check the current Zen page before you start.

Which free OpenCode model is the best?

It depends on the month, because the free list rotates. Start with whichever free Zen model is newest, and switch to a Gemini key if you need steadier limits.

Is my code safe with free models?

Not always. Free periods may involve prompts being used to improve models. For private code, use a local Ollama model or a paid provider with clear data terms.

Can I use OpenCode offline?

Yes, with a local model through Ollama. You need the model downloaded and enough RAM to run it.

What is the difference between OpenCode Zen and OpenCode Go?

Zen is a pay per use gateway that also includes some free models. Go is a monthly subscription for a bundle of open weight models.

The Real Takeaway

You do not need a paid subscription to start using an AI coding agent. Install OpenCode, connect a free Zen model, and you can be working in minutes. That is the whole point of this setup, and it is why I stopped before clicking that upgrade button.

But free works best when you treat it as a starting lane, not a permanent answer. The Zen free models are the fastest way to find out whether a terminal agent fits how you work. A free Gemini key gives you steadier daily headroom once you start leaning on it. OpenRouter is great for testing different models without committing to any of them. And a local Ollama model is the right choice whenever the code in front of you is private. Each one solves a different problem, so you can mix them instead of picking only one.

Stay realistic about the limits. Free models rotate, they can be slower, and they will sometimes get things wrong. Protect sensitive code, because free periods may involve your prompts being used to improve models. Review every diff before you accept it, and commit often so a bad edit never costs you more than a few seconds.

Most importantly, measure the right cost. If you spend your afternoon fixing weak output, free is not really free, because your time has a price. When that starts to happen, a cheap paid lane like OpenCode Go or a pay per use provider is a smart upgrade, not a failure. Until then, you have a capable setup that costs nothing.

If this helped you understand how to set up and use OpenCode for free — and how to get started with an AI coding agent without paying for an expensive subscription — a clap 👏 goes a long way. I’ll be sharing more practical insights on open-source AI tools, coding agents, free developer tools, AI-assisted programming, and workflows that make software development more accessible.

Follow Phynix AI for more practical AI, LLMs, OpenCode, Claude Code, coding, open-source models, AI agents, and developer-focused insights.