A step-by-step guide to setting up a fully local AI coding agent using Ollama as the model server, Gemma 4 (E4B variant) as the LLM, and OpenCode as the agent interface. Covers installation on Windows and Linux, downloading and configuring Gemma 4 with a 128K context window via a Modelfile, and connecting OpenCode to the local Ollama endpoint via an opencode.json config. The result is a privacy-preserving, cost-free coding agent that keeps all data on-device.
Table of contents
1. Install Ollama2. Download Gemma 43. Install OpenCode4. Connect OpenCode to Gemma 45. What Can You Do With This Setup?45 Impressions