Skip to content

Instantly share code, notes, and snippets.

@linyanm
Last active August 19, 2026 08:14
Show Gist options
  • Select an option

  • Save linyanm/d3c1cc210ba76e8609b363642ceaf3d7 to your computer and use it in GitHub Desktop.

Select an option

Save linyanm/d3c1cc210ba76e8609b363642ceaf3d7 to your computer and use it in GitHub Desktop.
opencode 桌面版通过 sub2api 接入 Muse Spark

opencode 桌面版通过 sub2api 接入 Muse Spark

适用于 opencode 桌面版 / CLI v2,模型 muse-spark-1.2-contributor 走自建 sub2api 中转
已按 v2 规范修正:variants 为数组 + settings,并补全 medium

前置

  • sub2api 已建独立分组(platform: openai,上游 https://opencode.ai/zen/go/v1),令牌 YOUR_SUB2API_TOKEN 仅返回 ["muse-spark-1.2-contributor"]
  • 中转:http://YOUR_SUB2API_HOST:8080/v1

1. 配置文件

  • 全局(桌面版通用):~/.config/opencode/opencode.jsonopencode.jsonc
  • 项目:./opencode.json
  • 桌面版与 CLI 共用同一套,改全局即生效

v2 键变更:npmpackageoptionssettingsvariants 由对象改为数组。旧写法会被静默忽略,导致“同一模型内 variants 未识别”。

文档:https://opencode.ai/docs/config/ · https://opencode.ai/docs/providers/ · https://opencode.ai/v2/docs/models

2. 配置(新建自定义提供商)

~/.config/opencode/opencode.jsonc

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "muse": {
      "package": "@opencode-ai/ai/providers/openai-compatible",
      "name": "Muse Spark (sub2api)",
      "settings": {
        "baseURL": "http://YOUR_SUB2API_HOST:8080/v1",
        "apiKey": "{env:SUB2API_MUSE_TOKEN}"
      },
      "models": {
        "muse-spark-1.2-contributor": {
          "name": "Muse Spark 1.2 Contributor",
          "modelID": "muse-spark-1.2-contributor",
          "capabilities": {
            "tools": true,
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 1048576,
            "output": 131072
          },
          "settings": {
            "reasoningEffort": "high",
            "reasoningSummary": "auto",
            "textVerbosity": "medium"
          },
          "variants": [
            {
              "id": "minimal",
              "settings": {
                "reasoningEffort": "minimal",
                "reasoningSummary": "auto",
                "textVerbosity": "low"
              }
            },
            {
              "id": "low",
              "settings": {
                "reasoningEffort": "low",
                "reasoningSummary": "auto",
                "textVerbosity": "low"
              }
            },
            {
              "id": "medium",
              "settings": {
                "reasoningEffort": "medium",
                "reasoningSummary": "auto",
                "textVerbosity": "medium"
              }
            },
            {
              "id": "high",
              "settings": {
                "reasoningEffort": "high",
                "reasoningSummary": "auto",
                "textVerbosity": "medium"
              }
            },
            {
              "id": "xhigh",
              "settings": {
                "reasoningEffort": "xhigh",
                "reasoningSummary": "detailed",
                "textVerbosity": "medium"
              }
            }
          ]
        }
      }
    }
  },
  "model": "muse/muse-spark-1.2-contributor#high"
}

要点:

  • 必须写 limit / capabilities:自定义 provider 不在 models.dev,缺 limit 会被 cap 到 32k 输出(#29363)
  • 思考强度 = 同一 models."muse-spark-1.2-contributor" 内的 variants 数组,每项 { id, settings }minimal/low/medium/high/xhigh 为 models.dev 官方 effort 全量(none 已于 #3347 移除,不支持)
  • 选择方式:muse/muse-spark-1.2-contributor#medium#high 等(provider/model#variant),桌面版 /models 也会列出
  • settings 在 provider → model → variant 三层合并,variant 最终覆盖。勿用旧的 options
  • apiKey{env:SUB2API_MUSE_TOKEN}{file:~/.secrets/muse-token}
export SUB2API_MUSE_TOKEN="YOUR_SUB2API_TOKEN"
# 图形启动的桌面版需写入 ~/.zshrc 或 launchd env,改后重启 opencode

3. 常见坑

  • variants 写成对象 {"high": {...}} → v2 需改为数组 [{"id":"high", "settings":{...}}]
  • optionssettingsnpmpackage
  • limit/capabilities → 上下文被截、工具调用失效
  • none 已不支持,Muse Spark 仅 minimal/low/medium/high/xhigh(models.dev #3347)

4. 验证

# 中转直测
curl -s http://YOUR_SUB2API_HOST:8080/v1/models -H "Authorization: Bearer YOUR_SUB2API_TOKEN" | jq .
curl -s http://YOUR_SUB2API_HOST:8080/v1/chat/completions \
  -H "Authorization: Bearer YOUR_SUB2API_TOKEN" -H "Content-Type: application/json" \
  -d '{"model":"muse-spark-1.2-contributor","messages":[{"role":"user","content":"ping"}]}' | jq .

# opencode 侧
opencode debug config | jq '.provider.muse.models."muse-spark-1.2-contributor".variants'

桌面版 /models 应出现 muse/muse-spark-1.2-contributor 及其 minimal/low/medium/high/xhigh


占位符 YOUR_* 替换为真实地址与令牌,切勿公开 sk-...

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment