Install and first request
Three steps: add the plugin, restart OpenCode, call it. You need OpenCode V2 (2.0.26 or later) with at least one provider login, and Bun.
1. Add the plugin
bunx opencode-plugboard@latest init --fast anthropic/claude-haiku-4-5Use a model you are logged in to. If you are not on Anthropic, leave --fast out and pick a model in step 3. @latest makes Bun fetch the current release: without it Bun can reuse an older copy, and init pins the version that ran.
This adds plugboard to your global config, ~/.config/opencode/opencode.jsonc, pinned to that release. It creates a key for one app (my-app; pick the name with --app), allows every model of every provider you are logged in to, and prints the key once with a ready curl. A config file it creates is readable by you alone (mode 0600, and 0700 for a directory it makes), because the key is in it; a file that already exists keeps its mode.
--fast <model>adds the aliasfast, which the examples below call.--dry-runshows the change without writing it.- An existing plugboard entry is kept unless you pass
--force. - The key is stored in the file, so keep the file private.
Or write the entry yourself
Plugboard keys are its own, not provider keys or the OpenCode server password. Keep the plugin in the global config: every project loads it.
{
"plugins": [
{
"package": "opencode-plugboard@0.69.0",
"options": {
"keys": { "my-app": "{env:PLUGBOARD_KEY_MY_APP}" },
"models": ["anthropic/claude-sonnet-4-6", "github-copilot/*", "opencode-go/glm-5.3-flash"],
"aliases": { "fast": "opencode-go/glm-5.3-flash" }
}
}
]
}keysnames each app and gives it a key.{env:VAR}is read from the environment OpenCode starts from, so the key stays out of the file.modelsis the allowlist."all"allows every model of every provider you are logged in to, including ones you connect later. A list (with*wildcards) allows only those. A model that is not allowed answers 404.aliasesgives a short name to a model. Every alias target must be allowed bymodels.
Keep the version pinned. A bare "opencode-plugboard" means latest, so a cache refresh can load code you have not read. Change the number on purpose, after reading the changelog. The snippet above always shows the latest release.
2. Restart OpenCode and touch the server once
OpenCode loads no plugin until a client connects, so the port stays closed until then:
opencode api get /api/agentFor an always-on server, run that call from the service unit. See Serving other machines.
3. Call it
The listener is on 127.0.0.1:4010. Put the key init printed in your shell (if you wrote the entry yourself, it is the value of PLUGBOARD_KEY_MY_APP):
export PLUGBOARD_KEY_MY_APP=<the key init printed>List the models the key may use. Any id works as model:
curl -s http://127.0.0.1:4010/v1/models -H "Authorization: Bearer $PLUGBOARD_KEY_MY_APP" | jq -r '.data[].id'This prints pong. Without the fast alias, use a model id from that list:
curl -s http://127.0.0.1:4010/v1/chat/completions \
-H "Authorization: Bearer $PLUGBOARD_KEY_MY_APP" \
-H "Content-Type: application/json" \
-d '{"model": "fast", "messages": [{"role": "user", "content": "reply with exactly: pong"}]}' \
| jq -r '.choices[0].message.content'The same call with the OpenAI Python SDK. Only the base URL and the key change:
import os
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:4010/v1", api_key=os.environ["PLUGBOARD_KEY_MY_APP"])
r = client.chat.completions.create(model="fast", messages=[{"role": "user", "content": "reply with exactly: pong"}])
print(r.choices[0].message.content)If it does not answer
| You see | It means |
|---|---|
| Connection refused | OpenCode has not loaded the plugin. Run step 2. After every restart, run it again. |
401 invalid_api_key | The key is missing, wrong, or not in keys. Use the key init printed, not a provider key. |
404 model_not_found | The model is not in models, the server does not have it enabled, or its provider is not signed in on the OpenCode server. GET /v1/models lists what you may use. |
401 provider_auth_failed | Your plugboard key is fine. The provider rejected the sign-in OpenCode holds for it: sign in again on the OpenCode server (/connect). |
403 no_models_configured | models is not set. Set "models": "all" or list models. |
| Connection refused after you edited the options | An option is wrong: the plugin failed to load. The OpenCode log has a plugboard options are invalid: line that names the option and, for an old name, the new one. |
403 invalid_host | A loopback listener saw a Host header that is not 127.0.0.1, localhost or [::1]. See Serving other machines. |
Open http://127.0.0.1:4010/ in a browser for a setup page: the listen address, the endpoints and a curl example. With keys set (as init does), a browser cannot send a key, so the page leaves out your models and aliases. curl -s http://127.0.0.1:4010/v1 -H "Authorization: Bearer $PLUGBOARD_KEY_MY_APP" returns them, with a models suggestion built from what your server offers.
Next
- Connect your app: choose by API or by client.
- Apps and keys: one key per tool.
- Configuration reference: every option.