| 两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 |
| 知识库:opencode指南 [2026/01/15 15:44] – 邪让多杰 | 知识库:opencode指南 [2026/01/23 09:31] (当前版本) – 邪让多杰 |
|---|
| ===== 简要步骤说明 ===== | ===== 简要步骤说明 ===== |
| |
| **完整配置只需 4 步:** | **完整配置只需 5 步:** |
| |
| - **步骤1** - 安装 OpenCode:运行安装命令 | - **步骤1** - 安装 OpenCode Desktop |
| - **步骤2** - 配置 API:在 opencode.json 中配置第三方渠道并设置环境变量 | - **步骤2** - 找到配置文件位置 |
| - **步骤3** - 安装 Oh My OpenCode 插件:在 OpenCode 中输入一句话即可 | - **步骤3** - 配置第三方渠道 |
| - **步骤4** - 切换模型:用 <color #ed1c24>/model</color> 切换到配置的模型 | - **步骤4** - 连接 Provider 并输入 API Key |
| | - **步骤5** - 选择模型 |
| |
| ---- | ---- |
| }, | }, |
| "models": { | "models": { |
| | "gpt-5.2": { |
| | "limit": { "context": 400000, "output": 8192 }, |
| | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| | }, |
| | "gpt-5.2-codex": { |
| | "limit": { "context": 400000, "output": 8192 }, |
| | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| | }, |
| | "claude-haiku-4-5": { |
| | "limit": { "context": 200000, "output": 8192 }, |
| | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| | }, |
| "claude-opus-4-5-20251101": { | "claude-opus-4-5-20251101": { |
| "limit": { "context": 200000, "output": 8192 }, | "limit": { "context": 200000, "output": 8192 }, |
| "modalities": { "input": ["text", "image"], "output": ["text"] } | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| }, | }, |
| "claude-opus-4-5-think": { | "claude-opus-4-5-aws": { |
| "limit": { "context": 200000, "output": 16000 }, | "limit": { "context": 200000, "output": 8192 }, |
| "modalities": { "input": ["text", "image"], "output": ["text"] } | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| | }, |
| | "claude-opus-4-5-fast": { |
| | "limit": { "context": 200000, "output": 8192 }, |
| | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| | }, |
| | "claude-opus-4-5-max": { |
| | "limit": { "context": 200000, "output": 8192 }, |
| | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| | }, |
| | "claude-sonnet-4-5": { |
| | "limit": { "context": 200000, "output": 8192 }, |
| | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| | }, |
| | "gemini-3-flash-preview": { |
| | "limit": { "context": 1000000, "output": 8192 }, |
| | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| | }, |
| | "gemini-3-pro-image-preview": { |
| | "limit": { "context": 1000000, "output": 8192 }, |
| | "modalities": { "input": ["text", "image"], "output": ["text", "image"] } |
| }, | }, |
| "gemini-3-pro-preview": { | "gemini-3-pro-preview": { |
| }, | }, |
| "glm-4.7": { | "glm-4.7": { |
| "limit": { "context": 128000, "output": 4096 }, | "limit": { "context": 128000, "output": 8192 }, |
| "modalities": { "input": ["text", "image"], "output": ["text"] } | |
| }, | |
| "gpt-5.2": { | |
| "limit": { "context": 128000, "output": 16384 }, | |
| "modalities": { "input": ["text", "image"], "output": ["text"] } | "modalities": { "input": ["text", "image"], "output": ["text"] } |
| } | } |
| | ''limit.output'' | 最大输出 token 数 | | | ''limit.output'' | 最大输出 token 数 | |
| |
| ==== 第四步:设置 API Key 环境变量 ==== | ==== 第四步:连接 Provider 并输入 API Key ==== |
| |
| <note important>OpenCode 通过环境变量读取 API Key,变量名格式为:''提供商名称_API_KEY''(全大写)</note> | - 打开 OpenCode Desktop |
| | - 点击左下角 **Connect provider** |
| **Windows 用户:** | - 输入 ''duojie'' |
| | - 输入你在令牌页面生成的 API Key |
| |
| 永久设置系统环境变量(推荐):右键"此电脑" → 属性 → 高级系统设置 → 环境变量 → 新建用户变量 | ==== 第五步:选择模型 ==== |
| * 变量名:''DUOJIE_API_KEY'' | |
| * 变量值:''你的API密钥'' | |
| |
| **macOS/Linux 用户:** | 在页面底部的下拉菜单中选择你配置的模型。 |
| | |
| <code bash> | |
| # 添加到 ~/.zshrc 或 ~/.bashrc | |
| echo 'export DUOJIE_API_KEY="你的API密钥"' >> ~/.zshrc | |
| source ~/.zshrc | |
| </code> | |
| | |
| ==== 第五步:启动并选择模型 ==== | |
| | |
| - 打开 OpenCode Desktop | |
| - 在页面底部的下拉菜单中选择你配置的模型 | |
| |
| ---- | ---- |