CLI · TESTED END TO END

Use OpenCode with a local LLM on Mac

Set up OpenCode with a local LLM on Mac using Bridge1. Copy its provider entry and check prompt rereads, plan mode and stored-key behavior.

Updated

OpenCode is tested end to end in real sessions. This does not guarantee every model behaves the same way.

A triangulated steel truss section has an orange diagonal member and rests on a plain base.

Before connecting OpenCode

OpenCode API and model names

OpenCode uses the OpenAI-compatible Chat Completions route, /v1/chat/completions, with a provider base URL ending in /v1.

OpenCode uses the same plain model ids as Pi.dev, Codex and Hermes Agent. Select bridge1/route1 to follow the model you pick in Bridge1; switching models needs no client config edit.

How Route1 chooses a model →

Start from the terminal

bridge1 launch opencode

What you skip
Bridge1 does not edit OpenCode’s saved configuration; it supplies provider settings through the environment. OpenCode may write its own files during a session.
Versions
OpenCode versions older than the tested version or in a different major are refused; newer minors warn, and newer patches within the tested minor are silent.
Needs
On macOS, starting OpenCode depends on model availability and your automatic-loading settings; the manual steps below still work.

Set up OpenCode

Add the generated bridge1 provider entry to ~/.config/opencode/opencode.jsonc. Copy the full entry from the Gateway panel for all onboarded models. This example shows Route1 and one onboarded model; your Gateway panel lists your own models.

  1. Copy the Gateway panel snippet for all onboarded models. Keep its generated model capabilities and limits. Copy it again after onboarding another model.
  2. Merge the bridge1 entry into the provider object in your OpenCode configuration.
  3. Use @ai-sdk/openai-compatible with options.baseURL and options.apiKey. The generated models object lists all onboarded models.
  4. A key stored with opencode auth login is separate from Bridge1. It does not update after a Bridge1 reinstall or key rotation.
  5. Set model to bridge1/route1 to follow Route1. Keep the generated attachment and modalities fields when they are present.
// Add this "bridge1" entry to the "provider" object in ~/.config/opencode/opencode.jsonc, // and set "model" to "bridge1/route1" "bridge1": { "npm": "@ai-sdk/openai-compatible", "name": "Bridge1", "options": { "baseURL": "http://127.0.0.1:54321/v1", "apiKey": "YOUR-GATEWAY-KEY" }, "models": { "route1": { "name": "route1", "attachment": true, "modalities": { "input": [ "text", "image" ], "output": [ "text" ] }, "limit": { "context": 262144, "output": 32768 } }, "mtp-qwen3.6-35b-a3b-gguf": { "name": "mtp-qwen3.6-35b-a3b-gguf", "attachment": true, "modalities": { "input": [ "text", "image" ], "output": [ "text" ] }, "limit": { "context": 262144, "output": 32768 } } } }

First connection check

In the OpenCode terminal UI, type bridge1: help in a chat to see status, list models, or load, switch or stop a model. If a model is not ready, Bridge1 explains the next step in the chat. You can turn chat controls off in Settings.

Check that it works

  1. Check OpenCode’s selected provider is Bridge1 and the model matches your choice. With bridge1/route1, confirm the selected model in Bridge1 too.
  2. Send a short question in OpenCode. A pass is a relevant ordinary answer, separate from any status command or model-list response.
  3. In a disposable project, ask OpenCode to write a greeting into a small text file. Read the saved file to check completion; plan mode does not block shell commands.

A connection test, model list or echoed reply cannot establish task completion in OpenCode. Keep the generated model capabilities and limits when checking a file task.

If something is off

SymptomWhat it usually meansWhat to checkMore help
Authentication still uses an old keyOpenCode can store a separate key.Check the key stored through opencode auth login after a reinstall or key rotation.OpenCode key setup
An onboarded model is missingThe copied models entry may be stale.Copy the full Gateway entry again and merge it into the provider object.Review model profiles
OpenCode still rereads the promptA changed prompt start can require a reread.Check for the same skill in both skill folders, as described below.Prompt-reread limits
Moving from plan to build rereads the chatThat transition has a documented reread.Review the published conditions below before a long session.Read speed conditions
A long session does not compactToken usage is not yet visible in Bridge1 replies.Do not assume automatic compaction; review shared context limits.Context and compaction limits

Versions

Bridge1 0.7.7 launches OpenCode 1.19.4, tested on macOS on 2026-10-27. This check used bridge1 launch opencode. Below the tested version or a different major version: refused. A newer minor of the same major proceeds with a one-line warning. A newer patch is silent. These are not the only versions that work; you do not need the tested version. The manual setup below was not re-tested at that version.

OpenCode: limits to check

Review OpenCode and shared client limits →

Other client setup guides

Request Bridge1 early access

OpenCode setup questions

Why can an OpenCode model switch reread the chat?

Switching between plan and build rereads the whole chat once (348 s at 98K tokens on Qwen3.6-35B). When the start of the prompt changes between runs, MLX models reread the chat once (about 100 s at 13K tokens on Qwen3.6-27B).

Will OpenCode plan mode block shell commands?

No. Plan mode does not block shell commands (checked on version 1.18.29); a local model may run one.

Why might OpenCode keep using an old gateway key?

OpenCode stores a key entered through opencode auth login separately. That stored key does not change when Bridge1 is reinstalled or its gateway key rotates. The generated provider entry includes apiKey.