dsh-image-gen:在 DeepSeek Harness 中生成 GPT Image 2 图片

前言

在 DeepSeek Harness(DSH)里做图像生成,除了调用模型,还要处理生成中的状态、取消、结果留存和客户端预览。Codex 的内建 image_gen 已经可以走 Codex 订阅请求,但其公开后端目前请求非流式 JSON 响应,UI 也没有特别明显的生成过程表达。

dsh-image-gen 保留兼容的 image_gen 工具名,在 DSH 中提供 GPT Image 2 生成能力:默认使用 dsh-codex-connect 的 ChatGPT OAuth,也可以显式使用 API key,并把最终图片作为 DSH 附件保存、回放和下载。

这是什么

dsh-image-gen 是 DeepSeek Harness 的 Web profile 插件,由 LeemanCheung 维护,采用 MIT 许可证。

它注册 Codex 兼容的模型工具名 image_gen,用于 gpt-image-2。插件支持两类鉴权路径:

  • 默认的 Codex 订阅路径:复用 dsh-codex-connect 的 refreshable ChatGPT OAuth credential。
  • 显式 API-key 路径:使用 DSH 配置的 Images API account。

完成后的图片会存入 DSH 的 immutable attachment store,支持 replay、lightbox preview 和 download。

核心能力

工具与调用

  • 注册 Codex 兼容的模型工具名 image_gen
  • 面向模型的 tool output 保持 text-only,图片引用保留在 UI metadata 中。
  • 适用于 nested Code Mode calls。
  • 生成中可以使用 DSH 现有 interrupt control 取消请求。

生成过程

  • Codex 订阅请求在拿到非流式结果前,显示 developing animation。
  • API-key 请求最多显示 3 个 provider-sent partial images。
  • partial frames 会在一个 animated developing plate 上交叉淡化,最终清晰成 final image。

结果留存

  • 只保存完成后的 final image。
  • 图片进入 DSH immutable attachment store。
  • 完成卡片支持 replay、lightbox preview 和 download。
  • 会话重载后仍可从同一卡片回放。

安装与启用

先检查第三方源码和 MIT 许可证。插件以当前 dsh 进程权限运行,安装前建议 pin release tag 或 commit。

默认 keyless 订阅路径需要先安装 dsh-codex-connect 并登录一次:

dsh plugin --profile web add dsh-codex-connect
dsh openai-codex login

再安装本插件:

dsh plugin --profile web add github:LeemanCheung/dsh-image-gen#v0.3.0

安装完成后,重启 DSH Host,并刷新 Web 页面。

本地开发可以使用:

git clone https://github.com/LeemanCheung/dsh-image-gen.git
cd dsh-image-gen
npm install
npm run check
dsh plugin --profile web add .

仓库提交了 lib/index.jslib/client.js,因此按固定 tag 从 Git 安装时不需要额外构建依赖。

典型用法

在 DSH 对话里自然描述即可,例如:

Generate a cinematic 16:9 product photograph of a translucent mechanical keyboard on a dark glass desk, violet rim light, no text.

模型会调用 image_gen。运行期间,卡片显示 developing animation;DSH 的 interrupt control 可以取消请求;完成后的卡片支持 preview 和 download。

工具选项

  • prompt:生成指令,长度 1 到 32,000 字符,且最多 64,000 UTF-8 bytes。
  • reference_image_path:可选 PNG、JPEG 或 WebP 路径。DSH 读取前会请求一次性审批,并标明文件和上传来源;字节会被校验但不立即存储,只发送到 API-key /images/edits 端点;Provider 成功后,才会作为 durable audit attachment 提交。

reference_image_path 编辑模式需要 authMode: api-key,或者 authMode: auto 且有 API-key fallback。private Codex subscription endpoint 不视为 edit API。

认证方式

authMode: auto 是默认行为。它会先询问已安装的 dsh-codex-connect 包,获取 DSH-owned、refreshable 的 ChatGPT OAuth credential,并且只发送到固定端点:

https://chatgpt.com/backend-api/codex/images/generations

如果 Codex credential 解析、兼容性检查或刷新因非取消原因失败,它会尝试 apiKeyEnv 指定的 DSH credential reference,默认是 OPENAI_API_KEY。两者都失败时,返回组合失败。

可选配置:

  • authMode: codex-subscription:禁止 API-key fallback。
  • authMode: api-key:只使用已配置的 Images API account。

不要把 OAuth token 或 API key 写进 cordis.patch.yml、聊天消息、Git 或截图。插件每次生成时解析认证,请求结束后不保留。

兼容性与验证

已验证环境:

  • DeepSeek Harness 0.1.0-rc.6
  • dsh-codex-connect 0.1.0-alpha.4.4
  • Node.js 24.15.0
  • DSH Web profile on Windows 11
  • 真实 Codex subscription generation、durable replay、Blob preview 和 download controls

Node.js 支持:^22.19.0>=24.0.0

验证日期:2026-08-15。

适用场景与注意

适合需要把 GPT Image 2 放进 DSH 对话流程,并希望保留最终图片作为 DSH 附件的场景。

使用时注意:

  • 默认订阅路径依赖 dsh-codex-connect 的一次登录。
  • API-key 路径需要可用的 Images API account。
  • reference_image_path 编辑模式不能依赖 private Codex subscription endpoint。
  • 插件会拒绝重定向、限制响应大小、通过 DSH 校验图片字节,并只重试 transient failures。
  • 包含中英文 UI copy,并支持 prefers-reduced-motion

链接

GitHub:

https://github.com/LeemanCheung/dsh-image-gen

社区目录线索:

https://www.skillhub.cn/plugins/LeemanCheung/dsh-image-gen

该目录链接来自插件线索,未在本次抓取材料中逐项核实。社区目录是独立站点,不等同于 DeepSeek 或幻方官方应用商店。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye