opencode
opencode is a terminal-based coding agent. It reads an
OpenAI-compatible provider from its config, so — like Hermes and
OpenClaw — it's a first-class connect
target: the proxy writes the config, and seeds it with the live model catalog,
for you.
Before you start
Do the shared setup from How-to guides first: the
proxy must be running (zs-proxy proxy start) and funded
(zs-proxy fund).
The quick way: zs-proxy connect opencode
zs-proxy connect opencode # configure opencode to use the proxy
zs-proxy connect opencode --model qwen3-coder # ...and set it as the default model
zs-proxy connect opencode --print # preview the merged config, write nothing
This merges a zerosignal provider into your existing
~/.config/opencode/opencode.jsonc (backing the original up to
opencode.jsonc.bak) using opencode's @ai-sdk/openai-compatible adapter. It's
JSONC, so your comments and other settings are preserved. What it writes:
{
"provider": {
"zerosignal": {
"npm": "@ai-sdk/openai-compatible",
"name": "ZeroSignal",
"options": {
"baseURL": "http://127.0.0.1:9376/v1", // your live proxy endpoint
"apiKey": "zerosignal-local" // placeholder — the proxy ignores it
},
"models": {
"qwen3-coder": {
"name": "qwen3-coder",
"limit": { "context": 262144, "output": 65536 },
"cost": { "input": 0.153, "output": 0.612, "cache_read": 0.0153, "cache_write": 0.153 }
}
// ...one entry per model in the live catalog
}
}
},
"model": "zerosignal/qwen3-coder" // only when you pass --model
}
opencode requires each model to declare both a context and an output limit,
so connect seeds the live catalog with each model's limit.context and
limit.output. When a model doesn't advertise a max output, connect falls
back to a sane budget (min(8000, context/4)) — the proxy still meters and bills
on actual usage, so this only affects opencode's own client-side reservation.
Pricing. connect also seeds each priced model with a cost block (USD per
1M tokens) so opencode's session-cost readout reflects real spend instead of $0.
The figures are the network's advertised rates grossed up by the protocol fee
— i.e. what you actually pay — taken from the cheapest operator serving each
model ("from $X"). Treat them as an estimate: the authoritative charge is the
amount the chosen operator signs on-chain, which connect can't know in advance,
and routing may land on a different-priced operator. cache_write mirrors the
input rate (ZeroSignal has no cache-write premium); free or unpriced models get
no cost block.
If opencode's config lives somewhere non-standard, point connect at it with
OPENCODE_CONFIG=/path/to/opencode.jsonc (or --config-path).
Select the model and run
Start opencode and pick a zerosignal/… model — type /models to open the
picker, or it'll use the default if you set one with --model:
opencode
Send a message; the first reply confirms the whole path — encrypt, pay, route — is working.
Troubleshooting
| Symptom | Fix |
|---|---|
connect says opencode wasn't detected | Name it explicitly — zs-proxy connect opencode configures the named tool even without detection, writing ~/.config/opencode/opencode.jsonc. |
| opencode isn't using the proxy | Pick a zerosignal/<model> in the /models picker, and confirm the zerosignal provider exists under provider in the config. |
| Connection refused / can't reach the endpoint | The proxy isn't running or the base URL is wrong. Confirm with curl http://localhost:9376/healthz and start it with zs-proxy proxy start. |
wallet_unfunded / payment errors | Add funds with zs-proxy fund — see Wallet & funding. |
What's next
- Connecting AI tools — every
connectflag and the other supported tools. - Routing preferences — pin an operator or set a price ceiling.
- Pricing — what an agent turn costs.
- How-to guides — connect another app.