Preface¶
When building agents in DeepSeek Harness (DSH), a common requirement is to have the model “draw an image” or “modify an image based on a reference” rather than redirecting users to a browser or a standalone script. If you wrap an image generation service with MCP, you often end up with an extra process and an additional set of operations to manage. This article introduces the community plugin dsh-imagegen (maintainer: Lujinan991, category: Model Inference): it is a native Cordis plugin for DSH that doesn’t rely on MCP wrapping and doesn’t require launching a separate image generation service. Agents use the generate_image tool to perform text-to-image generation, reference-based image editing, and PNG mask-based local editing. Results are written to DSH persistent attachments and previewed in the conversation.
What Is This¶
dsh-imagegen (npm package name @local/dsh-imagegen, current documentation version 0.2.0, MIT License) is designed for OpenAI-compatible Images APIs. After configuring parameters such as baseUrl, apiKey (or environment variables), and the model, the Host side calls the remote HTTPS interface (HTTP is allowed for local localhost/127.0.0.1). The plugin declares its DSH compatibility range in package.json:
"engines": { "dsh": ">=0.2.0-rc.2 <0.3.0" }
DSH determines compatibility solely based on engines.dsh. When the boundary version 0.3.0 appears, you should verify whether the plugin is still applicable.
Directory page: SkillHub - dsh-imagegen
Source code and documentation: GitHub - Lujinan991/dsh-imagegen
Core Features¶
Image Generation and Editing Modes¶
- Text-to-image generation: Submit a generation request with parameters such as
prompt. - Image editing (edit): Pass in
image_pathsand use natural language to describe what to preserve and what to modify. Multiple images can serve different purposes (e.g., a product image plus a color tone reference). - Local editing: In edit mode, additionally provide
mask_path. The PNG mask must match the dimensions of the first input image, with transparent areas indicating the regions to modify.
When the same prompt requires multiple versions, use the n parameter. Different materials should be called separately to avoid mixing unrelated images in a single request.
Configuration and Runtime Characteristics¶
On the “Plugins” page, enter the details of @local/dsh-imagegen. The lower half shows the “Image Generation API” form. After saving, the configuration is written to the current profile’s cordis.patch.yml and takes effect the next time generate_image is called, without requiring a restart. Configuration items include the API root URL (must include the root path such as /v1), API key, default model (default is gpt-image-2), size, quality, async submission mode, etc. For the complete field table, see the repository README.
size: adaptive: Infers portrait/landscape/square dimensions from orientation words in the prompt. If no orientation words are present, it falls back toauto.submitMode: async: Suitable for service providers that return atask_idinstead of directly returning images. The plugin submits with?async=trueand polls the task interface.fallbackEndpoints: Only switches to the next endpoint in sequence when the previous one is confirmed to have failed (e.g., connection failure, 429, 502/503/504), avoiding retries on requests that may have already been billed.
How Images Return to the Conversation¶
The original bitmap is saved via ctx.attachments.saveFile, and the preview is saved via ctx.attachments.saveImages as a native DSH persistent reference. The tool result contains image content, which is retained in the session log. The conversation includes loading states, preview retries, and an “Open Original Image” option. The plugin does not directly write binaries to the workspace. When project assets are needed, the agent should copy them from the attachment path using authorized file tools.
The image generation prompt principles referenced from Codex are registered through a separate system prompt section (without copying its built-in tools or scripts).
Installation and Activation¶
In the DSH “Plugins” page on the left side, enter the repository URL in the installation field:
git+https://github.com/Lujinan991/dsh-imagegen.git
If the session has the official plugin_manager tool enabled, you can also request installation:
{
"action": "install_bundle",
"target": "git+https://github.com/Lujinan991/dsh-imagegen.git"
}
For local development, you can replace it with the absolute path of the plugin directory, or install it as a link: dependency. Source code changes take effect on the next startup:
/absolute/path/to/dsh-imagegen
After installation, confirm that the plugin row dsh-imagegen is enabled. In the installation result, application being applied means it has been applied, and restart-required means a restart is needed. After modifying plugin code, you must completely exit the application and reopen it (the documentation example is ⌘Q followed by restart). Simply toggling the switch on the plugin page will not rebuild the browser-side module table.
Installing from git does not automatically update. To upgrade, you can execute (from the original documentation):
dsh plugin --profile desktop add github:Lujinan991/dsh-imagegen
Then completely exit and reopen. Configuration is saved in the profile’s cordis.patch.yml under the plugin id dsh-imagegen, so it won’t be lost upon reinstallation.
Typical Usage¶
Describe the image requirements in the conversation, and the agent will call generate_image. Example for text-to-image generation:
{
"prompt": "Product photography: a white ceramic cup on a gray desk, soft side lighting, preserving natural material details, no text, no logos.",
"size": "1536x1024",
"n": 1
}
Example for reference-based image editing:
{
"mode": "edit",
"prompt": "Only replace the background with a seaside sunset. Keep the product, shape, color, logo, and edges from the first image unchanged. The second image is only for color tone reference.",
"image_paths": ["product.png", "style-reference.png"]
}
Input files are read via DSH’s ctx.fs, without bypassing file permissions. When the configuration is empty, the plugin can still be loaded. It only returns actionable prompts when the interface address or key is missing during actual invocation.
If the configuration form is not editable in the deployment (missing settings UI or dsh-settings not mounted), you can write the YAML snippet provided on the plugin page into cordis.patch.yml and restart. In all three cases, generate_image can still generate images normally; what’s missing is only the UI editing capability.
Use Cases and Notes¶
Who is it for: Developers already running agents on DSH 0.2.x (>=0.2.0-rc.2) with an OpenAI-compatible image generation API (or a self-built gateway). It’s for those who want image generation and editing to stay in the same session with the same attachment system, rather than using external MCP services.
Please verify before use:
- The plugin runs with the current DSH process permissions. Read the source code and MIT License before installation to confirm that the API key and configurations like
downloadHostsmeet your security policies. - An incorrect
baseUrl(e.g., missing/v1) may return HTML instead of JSON, and the plugin will point this out. API keys should not be written into prompts, tool parameters, or the repository. - The default model
gpt-image-2is documented to not support native combinations with transparent background parameters. The plugin will reject such combinations rather than silently switching models. - Remote APIs require HTTPS. URL results are only downloaded from HTTPS hosts allowed by
downloadHosts, without carrying API keys.
The repository README states: In isolated runtime on DSH 0.2.0-rc.2, all 37 tests passed, and image-api.test.js uses a local mock without calling real image generation interfaces.
Conclusion¶
dsh-imagegen brings OpenAI-compatible image generation and editing into a native Cordis plugin for DSH: a single generate_image tool chain, persistent attachments, and conversation previews, covering engineering details such as async task-based service providers and fallback endpoints. This community plugin has no official affiliation with DeepSeek/Quant mill. SkillHub directory facilitates discovery, but facts and usage should be based on the GitHub README.
- Directory page: https://www.skillhub.cn/plugins/Lujinan991/dsh-imagegen
- GitHub: https://github.com/Lujinan991/dsh-imagegen