Introduction¶
In the development of DeepSeek Harness, integrating image generation capabilities usually requires handling details such as asynchronous task polling, local reference image upload, and file preview. The dsh-tool-image-gen plugin integrates with the ToAPIs asynchronous API, provides text-to-image and image-to-image tools, and simplifies these operations.
What Is This¶
This is a DeepSeek Harness image generation tool plugin maintained by zhangjunjesse. It integrates with the ToAPIs asynchronous API and provides text-to-image and image-to-image tools.
Core Features¶
- Text-to-image and image-to-image: Submit task → poll → download to workspace
generated/. - Transparent background generation: By setting
background: "transparent", it returns a PNG with an alpha channel. - Multiple image generation: The plugin achieves multi-image output through client-side concurrency compensation (the
nparameter is handled on the client side rather than the server side). - Asynchronous task polling: Automatically manages the process of submitting tasks and polling for results.
- Automatic local reference image upload:
referenceImagessupports local file paths and automatically uploads them to obtain a URL. - Multiple sizes and resolutions: Supports many aspect ratios, from 1:1 to 21:9, as well as 1k/2k/4k resolutions.
- Inline preview: Results are registered in the DSH attachment system; files larger than 5MB are automatically compressed (requires macOS
sips).
Installation and Enablement¶
- Install the plugin package:
cd ~/.dsh/profiles
npm install dsh-tool-image-gen
- The plugin includes a
cordis.patch.yml; DSH automatically reads it and injects the tool. You can also manually insert it intocordis.patch.yml:
- id: image-gen
name: 'dsh-tool-image-gen'
- Configure credentials:
# 编辑 ~/.dsh/.credentials.yaml
# chmod 600 ~/.dsh/.credentials.yaml
# 添加内容:
TOAPIS_API_KEY: 你的key
Configuration¶
The plugin allows default parameters to be overridden in a configuration file:
| Field | Default | Description |
|---|---|---|
apiKeyEnv |
TOAPIS_API_KEY |
Credential reference name |
baseURL |
https://api.toapis.com/v1 |
API base URL; mainland China networks should use https://api.toapis.cn/v1 |
model |
gpt-image-2.5-flare |
Default model; options include gpt-image-2.5-sunburst and gpt-image-2 |
size |
1:1 |
Default aspect ratio |
resolution |
1k |
Default resolution |
background |
Not set | Set to transparent to generate a transparent background |
maxImagesPerCall |
4 |
Maximum number of concurrently fanned-out tasks for a single call when n > 1 |
pollIntervalMs / maxAttempts |
3000 / 60 | Polling strategy |
timeoutMs |
600000 | Collaboration timeout |
outputDir |
<cwd>/generated |
Directory where images are saved |
Typical Usage¶
Text-to-image with a specified model and size:
{ "prompt": "赛博朋克城市夜景海报", "model": "gpt-image-2.5-sunburst", "size": "16:9", "resolution": "2k" }
Generate a transparent background sticker:
{ "prompt": "一个红色圆形贴纸", "background": "transparent" }
Generate multiple images at once:
{ "prompt": "a small red apple on a white table, studio lighting", "n": 3 }
Image-to-image (local path automatically uploaded):
{ "prompt": "把这张图改成水彩画风格", "referenceImages": ["/path/to/photo.png"] }
Upload a local image to get a public URL:
{ "filePath": "/path/to/photo.png" }
Use Cases and Notes¶
- ToAPIs is a third-party API platform with usage-based billing; you need to obtain your key yourself.
- The
nparameter uses client-side concurrency compensation and is not natively supported on the server side. It can result in multiple charges, so settingmaxImagesPerCallis recommended. - The VIP (
gpt-image-2.5-*-vip) / official variants are not currently supported; this plugin does not yet cover their parameters. - For very large images (>4.5MB), inline preview compression on Windows depends on macOS
sips; non-macOS platforms only save the file and do not display it.
Short Ending¶
This plugin wraps the asynchronous workflow of ToAPIs, enabling DSH agents to have image generation capabilities. For more details, see the source code: GitHub