2026-11-17-DSH接入讯飞星辰MaaS-SparkX2.6.md

DSH 接入讯飞星辰 MaaS(Spark-X2.6)— 2026-11-17

结果

DSH Web GUI 已多出一个 provider:讯飞星辰 Spark,模型 Spark-X2.6 (1M)。改完即热加载,不需要重启 DSH。

改了两个文件

文件改动
~/.dsh/.credentials.yamlrefs 增加 XFYUN_SPARK_API_KEY: "ak-ca7d…c33bd"
~/.dsh/profiles/web/cordis.patch.ymlllm-pi-ai.config.providers 增加 xfyun 块

备份:~/.dsh/profiles/web/cordis.patch.yml.bak-before-xfyun-<时间戳>(改动前原件)。

DSH 的 provider 配置在 profile 的 cordis.patch.yml,不在 ~/.dsh/settings.yaml(那是旧格式备份)。密钥统一放 .credentials.yaml 的 refs,provider 里用 apiKeyEnv 引用。两个文件都是热加载(patch 是 patchReload: live,credentials 有 chokidar watch)。

关键参数与踩点

项取值说明
baseURLhttps://maas-api.cn-huabei-1.xf-yun.com/v2只填到 /v2,插件自己拼 /chat/completions。/v1 实测也能通,但官方文档把它留给 /v1/responses;spark-api-open.xf-yun.com(旧星火 HTTP 接口)返回 404,别用
模型spark-x2.6上下文 1M,293B-A30B MoE,2026-10-20 上架
模型spark-x2.6-4b上下文 1M,4B 小模型(免费额度,2026-11-17 用户开通后追加),thinking 档位比 x2.6 严格
可用型号上述两个spark-x2.6-preview / spark-x2.5* 仍返回 11200 no valid authorization(账号无有效订单)
输入模态纯文本文档明确 content 数组当前只支持 type=text;传 image_url 报 10042(服务端拉图失败,不是不支持图片那么直白,但确实没有视觉能力)
思考控制thinking:{type:enabled|disabled|auto} + reasoning_effort: none|low|high两者都认、可并存;实测 medium/max 也不报错但只有 low/high 是真的分档 → compat 用 thinkingFormat: deepseek,max 归并到 high
输出长度max_completion_tokens官方已把 max_tokens 标废弃(仍兼容),maxTokensField: max_completion_tokens,模型档位设 65536
其它 compatsupportsDeveloperRole: false、requiresReasoningContentOnAssistantMessages: true讯飞只有 system 没有 developer;assistant 历史里回传 reasoning_content 实测被接受
超时streamIdleTimeoutMs: 6000001M 上下文,长 prompt 预填可能很久,默认 300s 会掐断流

实测记录(2026-11-17)

  1. GET /v1/models(和 /v2 等价)→ {"data":[{"id":"spark-x2.6",…}]}
  2. 普通对话:返回 content + reasoning_content,usage.completion_tokens_details.reasoning_tokens 有值
  3. reasoning_effort 三档对照(同一句「1+1=?」):
    • none → 正文 1+1=2,reasoning_tokens 0
    • low → 思考 73 token
    • high → 思考 158 token
  4. thinking:{type:"disabled"} + max_completion_tokens → 正文正常、reasoning_content: null
  5. 流式 tool_calls:首 chunk 带 function.name + call_id,后续 arguments 分片,finish_reason: "tool_calls" —— DSH 的工具调用链路可用
  6. 用 DSH 自己的适配层(@earendil-works/pi-ai 的 openai-completions)按上述 compat 发了一次真实请求,实际发出的 body:
    • 关思考:{"model":"spark-x2.6","messages":[…],"stream":true,"max_completion_tokens":512,"thinking":{"type":"disabled"}}
    • 高思考:… "max_completion_tokens":512,"thinking":{"type":"enabled"},"reasoning_effort":"high"}
    • 回来的是 thinking 块 + text 块,usage.reasoning=51 ✅

4B 补充实测(2026-11-17 追加)

用户开通免费额度后 GET /models 返回两个模型,4B 立即可用。

使用

回滚

cp -a ~/.dsh/profiles/web/cordis.patch.yml.bak-before-xfyun-* ~/.dsh/profiles/web/cordis.patch.yml
# 再从 ~/.dsh/.credentials.yaml 删掉 XFYUN_SPARK_API_KEY 一行

热加载,改完立刻回到接入前状态;不会影响其它 provider。

下载此文件