muxlayer
muxlayer guides/use-opencode-with-muxlayer

OpenCode

Use OpenCode with MuxLayer

MuxLayer turns OpenCode's model endpoint into a local MuxLayer entry while MuxLayer handles provider selection, model mapping, failover, diagnostics, request tracing, and cost tracking.

When to use this

Use this guide if you want:

  • OpenCode to switch between DeepSeek, MiMo, OpenAI, Kimi, GLM, DashScope, or another provider from one local UI.
  • The agentgate virtual model to resolve to the currently selected route model.
  • OpenCode requests to appear in the same request logs and cost dashboard as Codex and Claude Code.
  • One-click restore if you want to go back to the previous OpenCode config.

Quick Setup

  1. Download MuxLayer from Releases and open the app.
  2. Add at least one provider in Quick Setup or Providers.
  3. Start the gateway from Overview or Gateway.
  4. Open Clients and click Apply Config on the OpenCode card.
  5. Send a test prompt from OpenCode.
  6. Check MuxLayer Logs to confirm the OpenCode client, selected provider, model, and route.

What MuxLayer configures

OpenCode side MuxLayer side Provider side
OpenAI-compatible endpoint /v1/chat/completions local gateway route Chat-compatible upstream
openai/agentgate virtual model Route-selected real model Provider-specific model ID
Client config Snapshot before write One-click restore from MuxLayer

Troubleshooting

Symptom Check
OpenCode keeps using the old model Apply the OpenCode config again and restart OpenCode if needed.
The provider rejects the model Check Model Mapping and the provider default model.
Requests do not show in logs Confirm OpenCode is using 127.0.0.1:9090 as its base URL.
You changed providers but OpenCode still sends an old model name Use the agentgate virtual model path rather than hardcoding a provider model.

Related