OpenCode + OMO 配置教程

安装 OpenCode 与 OMO,并接入 Good API 的 OpenAI 兼容接口。

安装

1.1 Opencode安装

npm i -g opencode-ai

1.2 OMO安装

Opencode有自带的免费模型,可以让AI帮你装 OMO

你可以直接请求 OpenCode 帮你安装:

打开 OpenCode。

在对话框中输入:

"Install and configure by following the instructions here https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/refs/heads/master/README.md↗"

OpenCode 将会自动检测并执行安装脚本。

1.3 如果你想手动装,可以:

opencode

bunx oh-my-opencode install

第一条是确认 OpenCode 已经能启动。

第二条是安装 OMO。

2. API接入

中转用的网关,https://api.goodapi.click/v1支持 OAI -compatible 接口。

所以在 OpenCode 里,可以把它当成一个自定义的 OpenAI 兼容 provider 来接。

接入过程

2.1 找opencode.json

win下找到你的 C盘里的 user/.config/opencode.json

Linux 找 ~/.config/ opencode.json

2.2 配置json中的provider,也就是API供应商和供应的model

在 opencode.json 里加上这段吗,注意:不要直接复制,先替换你真正的api key进去:

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "自定义的provider名字": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "apiKey": "你的API Key",
        "baseURL": "https://api.goodapi.click/v1"
      },
      "models": {
        "gpt-5.4": {
          "name": "GPT-5.4",
          "limit": {
            "context": 1050000,
            "output": 128000
          },
          "maxTokens": 128000,
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "variants": {
            "low": {
              "reasoningEffort": "low",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "high": {
              "reasoningEffort": "high",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "medium": {
              "reasoningEffort": "medium",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "none": {
              "reasoningEffort": "none",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "xhigh": {
              "reasoningEffort": "xhigh",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            }
          }
        },
        "gpt-5.3-codex": {
          "name": "GPT-5.3 Codex",
          "limit": {
            "context": 400000,
            "output": 128000
          },
          "maxTokens": 128000,
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "variants": {
            "low": {
              "reasoningEffort": "low",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "high": {
              "reasoningEffort": "high",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "medium": {
              "reasoningEffort": "medium",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "xhigh": {
              "reasoningEffort": "xhigh",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            }
          }
        },
        "gpt-5.5": {
          "name": "GPT-5.5",
          "limit": {
            "context": 1050000,
            "output": 128000
          },
          "maxTokens": 128000,
          "modalities": {
            "input": ["text", "image", "pdf"],
            "output": ["text"]
          },
          "variants": {
            "low": {
              "reasoningEffort": "low",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "high": {
              "reasoningEffort": "high",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "medium": {
              "reasoningEffort": "medium",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "none": {
              "reasoningEffort": "none",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            },
            "xhigh": {
              "reasoningEffort": "xhigh",
              "reasoningSummary": "auto",
              "textVerbosity": "low"
            }
          }
        }
      }
    }
  }
}

内容整理自「OpenCode + OMO配置教程」,已针对网页阅读优化。