Back to Blog
AI & Technology

How to Use OpenCode with Free Zen Models in VS Code

OpenCode is an open-source AI coding agent that runs in your terminal. It connects to 75+ AI providers, understands your entire project context, and can read, edit, and create files across your codebase. The best part? It comes with free built-in models through OpenCode Zen — no credit card required.

In this guide, you will learn how to install OpenCode, connect to free Zen models, and integrate it seamlessly with VS Code for an AI-powered development workflow.

What is OpenCode?

OpenCode is a free, open-source AI coding agent built by the team behind SST (Serverless Stack). It has over 45,000 GitHub stars and is one of the most popular terminal-based AI coding tools available. Unlike Copilot or Cursor which are proprietary, OpenCode is fully open source, provider-agnostic, and privacy-first — your code never gets stored on their servers.

Key features:

What are OpenCode Zen Free Models?

OpenCode Zen is a curated list of free AI models hosted and verified by the OpenCode team. You can use them without providing any API key or payment method. The free tier is throttled per IP, but it is generous enough for daily development use.

Available free Zen models include:

You can also bring your own API keys for Claude, GPT-4, Gemini, or any other provider if you need more power. OpenCode switches between them seamlessly.

Step 1: Install OpenCode

OpenCode runs on macOS, Linux, and Windows (via WSL). The easiest way to install is with the install script:

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

Or install via npm:

npm install -g opencode-ai

On macOS, you can use Homebrew:

brew install opencode

Verify the installation:

opencode --version

Step 2: Connect to Free Zen Models

OpenCode needs a provider to work. To use the free Zen models, run the /connect command inside the OpenCode TUI:

opencode
/connect

Select opencode from the provider list. This will prompt you to visit opencode.ai/auth to sign in and get an API key. Sign in with your GitHub or Google account — no credit card is required.

Once you have your API key, paste it into the terminal prompt. OpenCode will now use the free Zen model tier by default.

To see which free models are available:

opencode models opencode

Step 3: Initialize OpenCode in Your Project

Navigate to your project directory and start OpenCode:

cd /path/to/your/project
opencode

Run the init command to let OpenCode analyse your project:

/init

This creates an AGENTS.md file in your project root with instructions about your project structure, coding patterns, and conventions. Commit this file to Git — it helps OpenCode understand your project every time you work on it.

Step 4: Integrate OpenCode with VS Code

OpenCode integrates with VS Code in two ways: the IDE Quick Launch feature and the VS Code extension.

Method 1: IDE Quick Launch (Built-in, No Extension Needed)

OpenCode has a built-in IDE Quick Launch feature. While using OpenCode in your terminal, press:

Cmd+Esc  (macOS)
Ctrl+Esc (Windows/Linux)

This opens VS Code (or Cursor, if installed) in a split view alongside your OpenCode terminal. OpenCode will open the relevant files in VS Code as it works on them, so you can see edits happening in real time.

You can configure which editor opens in the opencode.json config file:

{
  "ide": {
    "editor": "code",
    "openOn": "start"
  }
}

Set editor to "code" for VS Code, "cursor" for Cursor, or the path to your editor binary.

Method 2: VS Code Extension

Install the official OpenCode extension from the VS Code marketplace:

  1. Open VS Code, go to the Extensions panel (Cmd+Shift+X)
  2. Search for "OpenCode"
  3. Install the extension by Anomaly

Once installed, you can:

Method 3: Split Terminal Workflow

If you prefer a simpler setup, just run OpenCode in a VS Code integrated terminal:

  1. Open your project in VS Code
  2. Open the integrated terminal (Ctrl+`)
  3. Run opencode
  4. Keep the terminal on one side and your code on the other

As OpenCode makes changes, the file explorer will update, and you can click on filenames OpenCode mentions to jump directly to the changed code.

Step 5: Basic Usage & Commands

Here are the essential commands to get productive:

Ask Questions

Use the @ key to fuzzy-search for files in your project:

How is authentication handled in @src/utils/auth.ts

Plan Mode (Safe Exploration)

Press Tab to switch to Plan mode. OpenCode will explain how it will implement your request without making any changes.

[Tab to Plan mode]
Add a dark mode toggle to the settings page

Build Mode (Make Changes)

Press Tab again to switch back to Build mode and let OpenCode implement the changes:

[Tab to Build mode]
Now implement the dark mode toggle

Undo Changes

If OpenCode makes a change you do not like:

/undo

Switch Models Mid-Session

You can switch between different models without restarting:

/model kimi-k2.5

Start with a Specific Model

opencode --model opencode/kimi-k2.5

Step 6: Configure for Your Workflow

OpenCode is highly customisable. Create a opencode.json file in your project root:

{
  "provider": {
    "default": "opencode/kimi-k2.5",
    "fallback": "opencode/minimax-m2.1"
  },
  "agent": {
    "build": {
      "model": "opencode/kimi-k2.5"
    },
    "plan": {
      "model": "opencode/trinity-large-preview"
    }
  },
  "ide": {
    "editor": "code",
    "openOn": "start"
  },
  "keybindings": {
    "plan": "ctrl+shift+p",
    "build": "ctrl+shift+b"
  }
}

This configuration uses Kimi K2.5 for building code and Trinity for planning, with VS Code integration enabled.

Tips for the Best Experience

Limitations of Free Models

The free Zen models are powerful, but they have some limitations:

If you need more power, you can add your own API keys from Anthropic (Claude), OpenAI (GPT), Google (Gemini), or any other provider at any time. OpenCode will use your key automatically when available and fall back to free models for simple tasks.

Conclusion

OpenCode with free Zen models gives you a powerful AI coding assistant at zero cost. Combined with VS Code integration, it creates a seamless development workflow where you can ask questions, plan features, and generate code — all without leaving your editor. The open-source nature means no vendor lock-in, no subscription fees, and full control over your data.

Whether you are a student learning to code, a freelancer building client projects, or a professional developer looking to boost productivity, OpenCode's free tier is a great place to start. Install it, connect to Zen, and start coding with AI assistance today.

OpenCode AI VS Code Free Models Coding