OpenCode 配置指南:模型能力、模态与常用选项

opencode

opencode

Vllm
文本生成
Qwen

vllm + opencode打造AI coding应用,内置Qwen3-4B-Instruct-2507模型。

1. 配置文件结构

~/.config/opencode/opencode.json 示意:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["oh-my-opencode@3.1.2"],
  "mcp": {
    "feishu-mcp": {
      "type": "remote",
      "url": "https://www.feishu.com"
    }
  },
  "provider": {
    "Mify-OpenAI": {
      "npm": "@ai-sdk/openai",
      "options": {
        "baseURL": "http://www.baidu.com",
        "apiKey": "sk-..."
      },
      "models": {
        "azure_openai/gpt-5.1-codex": {
          "name": "GPT-5.1 Codex",
          "attachment": true,
          "reasoning": true,
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 1000000,
            "output": 128000
          }
        }
      }
    }
  }
}

2. 核心能力配置

配置项作用说明
modalities.input声明模型支持的输入类型可选值:text / audio / image / video / pdf;需要手动声明,否则视为不支持
modalities.output声明模型输出类型同上
attachment是否允许文件上传true 时可在对话中附加文件,常与 modalities 联动
reasoning推理模式true 时启用“思考过程”显示
limit.context / limit.outputToken 限制设定最大上下文与输出长度
options.*SDK 接入参数例如 baseURLapiKey、自定义 headerstimeout

只有配置了 modalities.input 包含 image 的模型才能接收图片输入;没有就会提示 “this model does not support image input”。

3. 常见场景示例

3.1 启用图片/多模态

"modalities": {
  "input": ["text", "image"],
  "output": ["text"]
},
"attachment": true

3.2 开启推理

"reasoning": true

3.3 设置 Token 限制

"limit": {
  "context": 1000000,
  "output": 128000
}

4. 其他可配选项速览

  • plugin: 安装的插件列表
  • mcp: MCP(如飞书)远程/本地服务描述
  • provider: 多个模型供应商配置(含 npm 包名、默认 options、模型清单)
  • workspace: 针对特定目录的覆写配置
  • env: 全局环境变量
  • instructions: 额外的规则/指令文件
  • tools: 控制可用工具(如禁用 bashwrite 等)
  • tui: 终端 UI 参数(滚动、diff 样式等)

5. 使用建议

  1. 逐级合并:Remote → Global → Custom → Project,后者可覆盖前者。
  2. 谨慎暴露密钥:推荐配合 {file:~/.secrets/...} 引用。
  3. 明确定义模态:缺省值即“不支持”,尤其图像、音频等必须显式声明。
  4. 模型专能化:同一 provider 下可配置多个 model entry,每个 entry 单独定义能力。

您可能感兴趣的与本文相关的镜像

opencode

opencode

Vllm
文本生成
Qwen

vllm + opencode打造AI coding应用,内置Qwen3-4B-Instruct-2507模型。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值