OpenCode-Notes

1. About

  • What is OpenCode?

    • OpenCode is an open source agent that helps you write and run code with any AI model. It’s available as a terminal-based interface, desktop app, or IDE extension.

2. Prerequisites

  • Node.js

3. Installation

  1. Install

    via node.js
    npm install -g opencode-ai@latest

4. Configuration

4.1. Ollama Provider

  • Reference this doc.

  • Edit opencode.json

    • Find the file

      Windows folder
      C:\Users\<user-name>\.config\opencode\
    • Add this code

      opencode.json
      {
        "$schema": "https://opencode.ai/config.json",
        "provider": {
           "ollama": {
             "npm": "@ai-sdk/openai-compatible",
             "name": "Ollama (Phoenix)",
             "options": {
               "baseURL": "http://192.168.1.53:11434/v1",
               "num_ctx": "65536"
             },
             "models": {
               "codellama:34b": {
                 "name": "CodeLlama 34b"
               },
               "deepseek-coder-v2:16b": {
                 "name": "Deepseek Coder -v2 16b"
               },
               "gpt-oss:20b": {
                 "name": "Gpt-OSS 20b"
               },
               "qwen3.5:27b": {
                 "name": "QWEN 3.5 27b"
               }
             }
           }
        }
      }