OpenCode 按照官方文档安装即可,官网有很详细教程
https://opencode.ai/docs/#%E5%AE%89%E8%A3%85
配置模型
安装完成后,编辑配置文件,在 ~/.config/opencode/opencode.json,添加模型提供商
{"$schema": "https://opencode.ai/config.json","provider": {"jnm": {"npm": "@ai-sdk/openai","name": "jnm","options": {"baseURL": "http://xxx/v1"},"models": {"gpt-5.3-codex": {"name": "GPT-5.3-codex","thinking": true,"modalities": {"input": ["text","image","pdf"],"output": ["text"]},"limit": {"context": 400000,"output": 128000},"options": {"store": false,"reasoningEffort": "xhigh","textVerbosity": "high","reasoningSummary": "auto","include": ["reasoning.encrypted_content"]}},"gpt-5.2-codex": {"name": "GPT-5.2 Codex","options": {"include": ["reasoning.encrypted_content"],"store": false}}}}}}
配置密钥
方式一:使用命令行(推荐)
# 登录或更新某个供应商的 Keyopencode auth login# 查看当前已配置的所有供应商和 Key 状态opencode auth list# 删除指定供应商的 Keyopencode auth logout <供应商名称>
方式二:手动编辑配置文件
在 ~/.local/share/opencode/auth.json 中添加对应供应商的 API Key
{"供应商名称": {"type": "api","key": "你的API密钥"}}
小技巧:在 OpenCode 中按 Ctrl + T 可切换不同的推理强度(variants)。
Copyright © Yisu Cloud Ltd. All Rights Reserved. 2018 版权所有
广州亿速云计算有限公司 粤ICP备17096448号-1
粤公网安备 44010402001142号 增值电信业务经营许可证编号:B1-20181529