How to Setup OpenCode & Gemma 4 Locally for Unlimited AI (100% Free)

If you have been following my Linux journey, you know I love hopping between different distros. But let’s be honest: troubleshooting Linux can sometimes be a nightmare. I don't like memorizing terminal commands. I’m a GUI (Graphical User Interface) person. So when things break, I rely on AI assistants to help me fix them. Recently, I was using an AI tool called Antigravity CLI to do this. It was super powerful, but it had one massive, incredibly frustrating catch: if you're on the free version, you hit the quota limit almost instantly, and you have to wait a whole week for it to reset.

In my last video, some of you awesome viewers recommended I try an open-source alternative called OpenCode. I gave it a shot, and not only did it solve my quota issues, but I also figured out how to hook it up to a local AI model for completely unlimited, private, and connected AI troubleshooting.

Here is exactly how I did it and why you should switch too.


What is OpenCode?

OpenCode is an open-source, AI-powered terminal assistant. It functions similarly to other terminal AI clients but puts you in control. It offers access to free cloud-based models, but its real superpower is its ability to connect directly to local models running on your own computer.

1. Getting Started with OpenCode

Installing OpenCode is incredibly easy. They support multiple packages like NPM, Bun, Homebrew, Paru, and Curl. I went with the quick Curl install:

curl -fsSL https://opencode.ai/install | bash

(Note: You have to restart your terminal after installation so it registers the opencode command.)

When I ran it for the first time, it didn't even ask me to sign in or create an account. I just typed opencode, hit enter, and was ready to go.

Trying "Build Mode"

To test it out, I switched OpenCode into Build Mode and asked it to install Minecraft on my system (CachyOS).

Instead of just telling me what to do, OpenCode took action. It:

  1. Ran system updates (sudo pacman -Syu).

  2. Checked if I had Flatpak installed (which I did).

  3. Automatically fetched and installed Minecraft from Flathub.

Just like that, Minecraft was installed and fully playable, with almost zero manual input from me!

2. No More One-Week Wait Times

OpenCode has a neat little meter on the bottom right that shows your current quota usage. While it does have limits on its default free models, the reset time is incredibly generous.

Unlike other tools that lock you out for an entire week, OpenCode's free model quotas reset every 5 to 16 hours depending on server traffic. But if you want to bypass quotas entirely, there's a better way.

3. Going Local: Unlimited AI with LM Studio & Gemma

To get unlimited AI access without server restrictions, I decided to connect OpenCode to my local machine's resources using LM Studio and Google's highly efficient Gemma model.

Because LM Studio exposes an OpenAI-compatible API, OpenCode can connect to it seamlessly.

How to set up Local AI in OpenCode:

  1. Open LM Studio on your PC.

  2. Load a lightweight, efficient model like Gemma 4 (it only uses about 4.8 GB of RAM, meaning it runs smoothly on almost any modern PC or even a phone!).

  3. Start the Local Server option inside LM Studio.

  4. In OpenCode, press Ctrl + P to bring up the menu, select Connect Provider, and choose your local LM Studio instance.

  5. OpenCode will scan, find your running model, and configure its config.json file automatically.

  6. Restart your terminal, launch opencode, and you are now using local AI!

Once configured, the quota meter completely vanishes. You now have unlimited AI access running directly on your CPU/GPU.

4. The Superpower: Local AI with Web Browsing (MCP)

Usually, running a local model means the AI is cut off from the internet and doesn’t know about recent events. However, OpenCode utilizes MCP (Model Context Protocol).

Even when using my local Gemma model, I asked OpenCode: "What is the latest Linux kernel version?" Right before my eyes, it executed a Web Fetch, searched the live internet, and retrieved the absolute latest kernel release date and version. It gives you the best of both worlds: the privacy and unlimited freedom of a local model combined with the real-time search capabilities of cloud AI.

The Verdict: Goodbye, Antigravity CLI!

I’ve already uninstalled my old AI troubleshooting tools. OpenCode is fast, deeply integrated with the terminal, respects my system resources, and costs absolutely nothing when self-hosted.

If you are a Linux user who wants an easier way to manage your system without getting bogged down by syntax, check out OpenCode and try running it locally. It has completely changed how I use Linux, and I think it will do the same for you.

I’ve also made a video on this topic — you can watch it below.

https://youtu.be/AVjO6AdDPf4

Check out my other posts, I post useful tutorials and tech tips, maybe you will find something useful 😉.

YouTube GitHub Twitter