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.js 和 lib/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 或幻方官方應用商店。

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

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

小夜