Back to Blog
ai-infraQwen 2.5 CoderOllamaOpenCodeLocal AIOffline Coding Assistant

Running Qwen 2.5 Coder Locally with OpenCode: A Private AI Coding Assistant

A complete setup guide for running Qwen 2.5 Coder locally via Ollama and connecting it to OpenCode, creating a private, offline-capable AI coding assistant in your terminal.

April 20, 2026·1 min read

Summary

A complete setup guide for running Qwen 2.5 Coder locally via Ollama and connecting it to OpenCode, creating a private, offline-capable AI coding assistant in your terminal.

Key Technical Findings

  • Setup involves installing Ollama and OpenCode on macOS, Linux, or Windows (WSL2).
  • Requires at least 8 GB of RAM (16 GB recommended for best performance).
  • Qwen 2.5 Coder model is pulled from Ollama with a command.
  • Configuration of OpenCode to use Qwen locally involves editing the opencode.json file to set num_ctx to 32768 for better context handling.

Commands Used

`curl -fsSL https://ollama.com/install.sh | sh` (for macOS/Linux)
`brew install ollama` (macOS Homebrew method)
`ollama --version` (to verify Ollama installation)
`ollama pull qwen2.5-coder` (to download the Qwen 2.5 Coder model)
`ollama list` (to confirm model is available)
`npm install -g opencode-ai` (to install OpenCode via npm)
`brew install sst/tap/opencode` (macOS Homebrew method for OpenCode)
`opencode --version` (to verify OpenCode installation)
Edit `~/.config/opencode/opencode.json` as per provided config
`ollama serve` (to start Ollama server)
`cd ~/projects/my-project && opencode` (to run OpenCode in a project directory)

Lessons Learned

  • Increasing num_ctx to 32768 improves context handling for coding tasks.
  • Tool calls may not work if the context window is too small; increasing num_ctx can resolve this.