Setting up OpenCode with Ollama and sbx on Mac

Sep 11, 2026 07:45 AM - 8 hours ago 4
Software development

Adam Lusted10 September 20263 min read

How to get started pinch moving Ollama section models pinch Opencode and Docker Sandboxes.

Viable section LLM improvement is here. With powerful models for illustration Qwen 3.8 and Gemma4 we tin now yet usage these models to build retired web applications. I'm utilizing a Apple Macbook pro m5 48GB model. I deliberation this is the saccharine spot for section improvement arsenic it allows you to tally 30B models pinch a decent sized context.

Why I usage Ollama. To beryllium frank it's conscionable easy. It has mlx now, truthful it's accelerated connected Apple silicon. It has a beautiful bully exemplary directory. It is besides very unchangeable and won't crash.

Why Opencode. Well, we request to commencement location pinch this blog and opencode is simply a awesome harness.

There is 1 different instrumentality that I use, docker sandboxes aka sbx. I usage frontier models astatine activity which require america to sandbox our harnesses. I also, for illustration to tally my section models successful containers arsenic they tin conscionable arsenic easy messiness up your machine pinch a unwanted hallucination.

Installing the tools

Install Docker Sandbox:

brew spot docker/tap && brew instal docker/tap/sbx

Install Opencode:

brew instal anomalyco/tap/opencode

Install Ollama:

To instal ollama, goto https://ollama.com/ and download and instal the app.

Installing the models

For the models, we'll propulsion 2 models. First guarantee ollama is running.

Qwen 3.8 27B mxfp8 (32GB): This is simply a awesome workhorse exemplary that will do astir of your agelong moving activity and tin tally undisturbed for aggregate hours wrong opencode.

ollama propulsion qwen3.8:27b-mxfp8

Gemma 4 31b mxfp8 (34GB): This is simply a awesome large dense exemplary erstwhile you request thing bigger.

ollama propulsion gemma4:31b-mxfp8

Note: If you don't person the 48GB Apple, you tin propulsion the modular models: qwen3.8:27b-mlx and gemma4:31b-mlx .

Configuring your project

For this setup, it requires you to setup a sbx kit for each project. A kit is simply a measurement to customise the sandbox. Create the pursuing folders and files:

./sbx-kit/files/home/.config/opencode-local.json ./sbx-kit/spec.yaml

spec.yaml

schemaVersion: "2" kind: mixin name: local-ollama-opencode version: "0.1.0" displayName: Local Ollama for OpenCode description: Configure OpenCode in Docker Sandboxes to use Ollama running on the Mac host. requires: agent: opencode environment: variables: OPENCODE_CONFIG: /home/agent/.config/opencode-local.json permissions: network: allow: - localhost:11434 - localhost:5173 - localhost:4000 agentInstructions: content: | Local Ollama runs connected the big machine. Default model: qwen3.8:27b-mxfp8 Deep record study / reasoning: gemma4:31b-mxfp8

opencode-local.yaml

{ "$schema": "https://opencode.ai/config.json", "model": "ollama/gemma4:31b-mxfp8", "small_model": "ollama/gemma4:31b-mxfp8", "lsp": false, "provider": { "ollama": { "npm": "@ai-sdk/openai-compatible", "name": "Mac Ollama", "options": { "baseURL": "http://host.docker.internal:11434/v1" }, "models": { "qwen3.8:27b-mxfp8-64K": { "id": "qwen3.8:27b-mxfp8", "name": "Qwen 3.8 27B MXFP8 [31 GB] [64K ctx]", "limit": { "context": 65536, "output": 8192 }, "variants": { "low": { "reasoningEffort": "low" }, "medium": { "reasoningEffort": "medium" }, "high": { "reasoningEffort": "high" }, "xhigh": { "reasoningEffort": "xhigh" } } }, "gemma4:31b-mxfp8": { "name": "Gemma 4 31B MXFP8 [33 → ~50 GB] [256K ctx]", "limit": { "context": 262144, "output": 8192 } } } } } }

For the qwen model, we've constricted the discourse to 64k, this will guarantee your strategy dose not fastener up erstwhile it runs retired of memory. We besides request 3GB for the sandbox.

Run Opencode

To tally opencode, tally the following:

sbx tally opencode --kit ./sbx-kit/

This will commencement Opencode pinch Qwen selected. Ensure you alteration down to "low" effort via /models command.

You should beryllium bully to go.

Note: You will request to login into Docker to tally sbx. This characteristic is not really liked by the improvement organization but location is nary measurement astir it.

opencode
More