快速开始
OpenCode 配置教程
按分组平台选择对应 provider 配置,并保存 opencode.json。
OpenCode 的配置会随当前 Key 所属分组平台变化。这篇文档给的是公开占位示例,结构与 `/dashboard/keys` 的“使用密钥”弹窗保持一致。
开始前建议先完成 Node.js 环境安装教程。
第一步:确认本地已安装 OpenCode
如果本地还没安装 OpenCode,先按 OpenCode 官方方式安装。本页只说明甜酒配置文件怎么写,不重复官方安装说明。
第二步:按分组平台选择对应配置
OpenCode 的配置会跟你当前这条 Key 所属分组的平台一起变化。先确认你拿到的是哪一类分组,再选择对应的 JSON。
- OpenAI 分组使用 `OpenAI` 版本的 `opencode.json`。
- Anthropic 分组使用 `Anthropic` 版本。
- Gemini 分组使用 `Gemini` 版本。
- Antigravity 如果同时接 Claude 和 Gemini,可以分别保存两份配置。
第三步:写入 opencode.json
下面的示例已经和 `/dashboard/keys` 里的“使用密钥”弹窗保持一致。实际使用时,把 `YOUR_TIANJIU_API_KEY` 替换成你自己的 Key。
{
"provider": {
"openai": {
"options": {
"baseURL": "https://api.tianjiu.ai/v1",
"apiKey": "YOUR_TIANJIU_API_KEY"
},
"models": {
"gpt-5-codex": {
"name": "GPT-5 Codex",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {}
}
},
"gpt-5.1-codex": {
"name": "GPT-5.1 Codex",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {}
}
},
"gpt-5.1-codex-max": {
"name": "GPT-5.1 Codex Max",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {}
}
},
"gpt-5.1-codex-mini": {
"name": "GPT-5.1 Codex Mini",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {}
}
},
"gpt-5.2": {
"name": "GPT-5.2",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
},
"gpt-5.4": {
"name": "GPT-5.4",
"limit": {
"context": 1050000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
},
"gpt-5.4-mini": {
"name": "GPT-5.4 Mini",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
},
"gpt-5.4-nano": {
"name": "GPT-5.4 Nano",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
},
"gpt-5.3-codex": {
"name": "GPT-5.3 Codex",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
},
"gpt-5.2-codex": {
"name": "GPT-5.2 Codex",
"limit": {
"context": 400000,
"output": 128000
},
"options": {
"store": false
},
"variants": {
"low": {},
"medium": {},
"high": {},
"xhigh": {}
}
}
}
}
},
"agent": {
"build": {
"options": {
"store": false
}
},
"plan": {
"options": {
"store": false
}
}
},
"$schema": "https://opencode.ai/config.json"
}默认文件名是 `opencode.json`。如果你同时需要 Antigravity 的 Claude 和 Gemini 配置,可以像上面的标签一样分别保存两份。
第四步:验证连接
- 如果启动后提示鉴权失败,先确认 `apiKey` 是否已经替换成你自己的甜酒 Key。
- 如果模型不可用,优先检查你选择的 provider 配置是否和当前分组平台一致。
- 如果你同时维护多份 `opencode.json`,先确认当前实例实际读取的是哪一份文件。