Introduction¶
To use OpenCode Zen models within dsh, the public /zen/v1 channel consumes public quota. Another approach is to run opencode serve locally: the opencode client channel (opencode.ai/zen/go/v1) does not require an OpenCode API key and does not occupy public quota, but this path does not integrate into dsh’s provider system by default.
The use-opencode-local-provider introduced below handles this wiring: it launches a local OpenAI-compatible bridge, converts dsh’s chat completions requests into opencode serve sessions, and makes OpenCode Zen appear in dsh’s chat UI under the name opencode-local.
What is this¶
use-opencode-local-provider is a dsh plugin maintained by Payel-git-ol, licensed under MIT, version 0.2.0, with the entry point ./lib/index.js. In one sentence, it packages local opencode serve (using the OpenCode Zen client channel) as a provider within dsh. It is categorized under “Model Inference” on the directory page.
DSH’s philosophy is “Everything is a plugin,” and tasks like provider integration are perfectly suited for plugins.
How it works¶
When the plugin loads, it performs three tasks:
- Ensures that a
opencode serveinstance is running, starting it automatically if necessary. - Launches a small OpenAI-compatible bridge that provides
/v1/chat/completionsand/v1/modelsendpoints, converting each request into an opencode serve session via opencode’s local HTTP API. - Registers the
opencode-localprovider route in the llm-pi-ai settings area, after which it will automatically appear in the dsh UI.
The request flow uses the opencode client channel opencode.ai/zen/go/v1, which requires no OpenCode API key and consumes no public /zen/v1 quota.
Installation and Usage¶
First, install the plugin. Go to the profile directory (~/.dsh/profiles/<profile>) and execute:
dsh plugin --profile <profile> add use-opencode-local-provider
Next, write the plugin into cordis.patch.yml and specify the models to expose to dsh:
- entry: use-opencode-local-provider
config:
models: [deepseek-v4-flash-free, hy3-free]
Restart the dsh process. After the steps above, the opencode-local provider will appear in the chat UI. If models is not configured, the full OpenCode Zen directory is exposed by default.
Configuration¶
The plugin’s configurable items and default values are as follows:
| Key | Default Value | Description |
|---|---|---|
opencodeBin |
opencode |
Path to the opencode executable |
serverHost |
127.0.0.1 |
Host for the opencode serve instance |
serverPort |
17655 |
Port for the opencode serve instance |
bridgeHost |
127.0.0.1 |
Binding host for the local OpenAI-compatible API |
bridgePort |
17656 |
Binding port for the local OpenAI-compatible API |
providerId |
opencode-local |
Route name in llm-pi-ai settings |
providerName |
OpenCode Local |
Display name in dsh UI |
apiKeyEnv |
OPENCODE_API_KEY |
Environment variable name used by dsh as provider credential (the bridge ignores this; pi-ai still requires a credential) |
models |
Full OpenCode Zen directory | Model IDs exposed to dsh |
directory |
process.cwd() |
Working directory for opencode sessions |
streamTimeoutMs |
600000 |
Maximum wait time for model completion (including multi-step tool execution) in milliseconds |
permissionReply |
once |
Auto-reply to opencode permission requests: once, always, or reject (if set to false, never auto-reply) |
Points to watch out for:
apiKeyEnv: The request flow itself does not require an OpenCode API key, and the bridge ignores the value in this variable, but pi-ai still requires a credential for the provider, so this environment variable name must be retained.permissionReply: Defaults toonce, automatically replying to opencode permission requests. If set tofalse, it will not auto-reply; execution will wait for manual response or until timeout.streamTimeoutMs: Defaults to 600000 milliseconds, covering the entire model completion process including multi-step tool execution; pay attention when running long tasks.
Tools and MCP¶
This is a distinctive part of the plugin. The bridge allows the model to use opencode’s built-in tools, including connecting to opencode’s MCP server. Tool calls are executed by opencode’s agent within the opencode session, equipped with its own sandbox and permission rules; the bridge only ensures execution continues and finally returns the answer. Pending permission requests will be automatically replied to according to the permissionReply configuration.
For dsh’s agent, these tools are invisible: dsh only sees a chat completions endpoint and cannot plan or observe tool calls; when to use tools is decided by the model itself. If the workflow depends on dsh-side awareness and orchestration of tool calls, this needs to be considered first.
Local Development¶
To run the source code locally, follow these two steps:
npm install
node -e "import('./lib/index.js').then(m => console.log(Object.keys(m)))"
The second command loads ./lib/index.js and prints the names of the exported modules, used to confirm the entry is available. type in package.json is module.
Suitable Scenarios and Notes¶
Suitable scenarios: already using opencode locally, want to call OpenCode Zen models in dsh directly, want the model to utilize opencode’s tools and MCP servers within the session, and do not wish to consume the public /zen/v1 quota.
Pre-use notes:
- The plugin runs with the permissions of the current dsh process; it is recommended to read the source code and confirm the license (MIT) meets your requirements before installing.
- Tool calls are invisible to dsh; dsh only sees a chat completions endpoint. Scenarios that require dsh-side planning or observation of tool calls are not suitable for this plugin.
- When
permissionReplyis set tofalse, execution waits for a manual response or until timeout; long tasks need to be considered in conjunction with the value ofstreamTimeoutMs. opencode serveand the bridge default to binding127.0.0.1, with ports 17655 and 17656 respectively. If these conflict with other local services, they can be adjusted in the configuration.
Summary¶
use-opencode-local-provider uses a small bridge to connect local opencode serve into dsh: it does not require an OpenCode API key, does not occupy the public /zen/v1 quota, and brings opencode’s tools and MCP to the model. Check the source code before installing, configure models and permissionReply, and restart dsh to use it directly in the UI.
The plugin is listed in the community directory (independent site, no official affiliation with DeepSeek or Hypersphere):
- Directory page: https://www.skillhub.cn/plugins/Payel-git-ol/use-opencode-local-provider
- GitHub repository: https://github.com/Payel-git-ol/use-opencode-local-provider