Connect your tools
OpenCode
Add an openai-compatible provider in opencode.jsonc.
About 6 minFor:Developers who use OpenCode in the terminal
Before you start
- OpenCode is installed and
opencoderuns - A key and a model name copied from the model plaza
Step 1 · STEP 0x01
Write opencode.jsonc
Create opencode.jsonc in the project root (or OpenCode's global config location) and add a provider under providers. The key is the provider ID, and models are referenced as provider-id/model-id:
$ cd your-project$ $EDITOR opencode.jsonc
{
"$schema": "https://opencode.ai/config.json",
"providers": {
"myrelay": {
"name": "My relay",
"env": ["MYRELAY_API_KEY"],
"package": "@opencode/ai/providers/openai-compatible",
"settings": {
"baseURL": "https://api.suanlimao.shop/v1"
},
"models": {
"<MODEL_NAME>": { "name": "<MODEL_NAME>" }
}
}
}
}settings.baseURLishttps://api.suanlimao.shop/v1; the official examples all include /v1.envlists the environment variables that hold the credential, hereMYRELAY_API_KEY.settings.apiKeyalso works (sent as a Bearer token) but keeping the key out of the file is better.modelsis keyed by model ID withnameas the display name. For Responses-only models setpackageto@opencode/ai/providers/openai-compatible/responses; for Claude-family models use@opencode/ai/providers/anthropic-compatiblewithbaseURLset tohttps://api.suanlimao.shopwithout /v1.
Step 2 · STEP 0x02
Set the key and start
export MYRELAY_API_KEY=<YOUR_API_KEY>$ export MYRELAY_API_KEY=<YOUR_API_KEY>$ opencode> /models # 选 myrelay/<MODEL_NAME>
- The variable name must match the one in
env. After starting OpenCode use/modelsto pickmyrelay/<model>.
Step 3 · STEP 0x03
Send a message to verify
> 用一句话介绍这个仓库(模型开始回答,并按需读取文件)
provider / npm / options). This follows the current official providers / package / settings shape; if your version reports a config error, compare with the Custom section of the official docs.✓ How to tell it worked
/modelslistsmyrelay/<model>and chat answers.- The Usage page shows the request.
FAQ
No credential / 401?
The variable name must match env and be exported before starting opencode.
I get 404.
Check baseURL is https://api.suanlimao.shop/v1 and the models key matches the plaza.
The model stops after one turn or tool calls misbehave.
Use a model marked as tool-calling on the plaza; for Responses-only models switch to the …/openai-compatible/responses package.
Related tutorials
Still stuck?
Read the troubleshooting tutorials first. If that does not help, open a ticket with the request_id, time, model and the exact error (never paste your key).