在 OpenCode 中使用 Codex 模型

本指南将帮助你在 OpenCode 中配置和使用 Codex 模型(如 gpt-5.3-codex)。

开始之前

请确保你已准备好:

配置步骤

1
安装 bun

Mac / Linux:

curl -fsSL https://bun.sh/install | bash

Windows(PowerShell):

irm https://bun.sh/install.ps1 | iex

Windows 如果被阻止,先执行 Set-ExecutionPolicy -Scope CurrentUser RemoteSigned 后重启终端。

2
安装 opencode 插件

切换到 OpenCode 配置目录并安装插件:

# Mac/Linux
cd ~/.config/opencode

# Windows (PowerShell)
cd C:\Users\你的用户名\.config\opencode

# 安装插件
bun add github:GreyElaina/opencode-omit-max-tokens
3
配置 opencode.json

配置文件位置:

  • Windows: C:\Users\你的用户名\.config\opencode\opencode.json
  • Mac / Linux: ~/.config/opencode/opencode.json

使用以下配置(替换 API 密钥):

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "opencode-omit-max-tokens"
  ],
  "provider": {
    "mmkg": {
      "npm": "@ai-sdk/openai",
      "name": "YY52",
      "options": {
        "baseURL": "https://yy.52ai.ai/v1",
        "apiKey": "sk-你的API密钥",
        "compatibility": "openai-responses",
        "omitMaxOutputTokens": true
      },
      "models": {
        "gpt-5.3-codex": {
          "name": "gpt-5.3-codex",
          "options": {
            "reasoning": { "effort": "high" },
            "store": false
          }
        },
        "gpt-5.2": {}
      }
    }
  }
}
4
重启终端

重启终端后选择配置的模型即可使用。

常见问题

无法连接?

下一步