OpenCode CLI 配置
通过 opencode.jsonc 将 OpenCode 接入 SimiRouter,支持 Linux、macOS 和 Windows 全平台。
OpenCode 使用全局配置文件:
- Linux / macOS:
~/.config/opencode/opencode.jsonc - Windows:
%USERPROFILE%\.config\opencode\opencode.jsonc
使用顺序:先将 API 密钥写入配置文件的 apiKey,再运行验证命令。此示例没有引用环境变量,无需额外设置 SimiRouter_API_KEY。请保护包含密钥的配置文件,并保留 OpenCode 默认权限确认。
配置文件(opencode.jsonc)
将以下内容写入配置文件,并将 apiKey 替换为自己的 API 密钥:
{
"$schema": "https://opencode.ai/config.json",
"model": "openai/gpt-6-astra",
"small_model": "openai/gpt-6-astra",
"provider": {
"openai": {
"options": {
"baseURL": "https://api.dwchainless.com/v1",
"apiKey": "替换为自己的 API 密钥"
},
"models": {
"gpt-6-astra": {
"headers": {
"originator": "opencode"
}
}
}
}
},
"agent": {
"title": {
"options": {
"reasoningEffort": "none"
}
},
"build": {
"variant": "xhigh",
"options": {
"reasoningSummary": "detailed",
"textVerbosity": "high"
}
},
"plan": {
"variant": "xhigh",
"options": {
"reasoningSummary": "detailed",
"textVerbosity": "high"
}
}
}
}验证配置
Linux / macOS
opencode debug config
opencode run "你好"Windows CMD
opencode debug config
opencode run "你好"Windows PowerShell
opencode debug config
opencode run "你好"opencode debug config 可验证配置是否正确加载;opencode run "你好" 用于测试模型是否正常响应。