OpenCode access
Use OpenCode official custom model service format. Select OpenAI-compatible here, which is called through the /v1/chat/completions dialogue interface of this site.
If not yet installed, follow OpenCode getting started to install the client.
Configuration
Merge the following content in user configuration ~/.config/opencode/opencode.json or opencode.json in the project root directory, retaining other settings. Windows users also use the .config/opencode path under the user directory. If the client sets other configuration directories, the actual directory shall prevail.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"shanhai": {
"npm": "@ai-sdk/openai-compatible",
"name": "ShangHai Do",
"options": {
"baseURL": "https://shanghaido.com/v1",
"apiKey": "{env:SHANHAI_API_KEY}"
},
"models": {
"qwen3.8-flash": {
"name": "Qwen 3.8 Flash"
}
}
}
},
"model": "shanhai/qwen3.8-flash"
}
Set the current terminal environment variables before starting:
$env:SHANHAI_API_KEY = "YOUR_API_KEY"
opencode
Linux or macOS corresponds to export SHANHAI_API_KEY="YOUR_API_KEY". If using another ShangHai Do site, replace the domain name in baseURL and retain /v1. In the configuration, shanhai is the custom model service identifier, and qwen3.8-flash must be exactly the same as the model name of this site. After startup, /models can be used to select shanhai/qwen3.8-flash. You can also use the official /connect custom model service process to save credentials.
Confirm whether it is successful
Send a simple question first, then try to get the tool to read a project file. Continuous output means that the server sends text paragraph by paragraph, and the client needs to continue reading until the end mark.
Please fill in the context length, image input capability and thinking parameters according to the model details, do not speculate on your own. When encountering "thinking mode does not support required/object tool_choice", check whether the tool is forcibly selected; please set tool_choice to "auto" to let the model automatically choose whether to call the tool.
References: OpenCode provider documentation, Configuration guide.
encountered a problem
If you encounter problems with calling or configuration, please contact the site customer service and provide the model name, error time and error information to facilitate troubleshooting.