dsh-image2-tool: Integrate a Self-hosted OpenAI-compatible Image Proxy in DSH

Introduction

When working with DeepSeek Harness (DSH) to generate images with an Agent, the common approach is to write standalone scripts or manually call HTTP endpoints, then paste the file path back into the conversation. To display images directly in replies, you often need to handle rendering yourself. The community plugin dsh-image2-tool (repo 544244857/dsh-image2-plugin) wraps text-to-image and image-to-image generation into a host tool image2_generate, connecting to your self-hosted OpenAI-compatible image relay server, and relies on bundle dependencies to render results inline. Below are the installation, configuration, and usage instructions.

What Is This

dsh-image2-tool is a Cordis bundle plugin for DeepSeek Harness (npm package name dsh-image2-tool, current release version 0.4.1). The maintainer is 544244857, and it is categorized as a networked tool in the SkillHub community directory. The plugin does not include its own image generation model; instead, it forwards POST /images/generations (text-to-image) and POST /images/edits (image-to-image) to your configured baseUrl. It supports relay servers returning b64_json or image URLs. Installation also brings in @wisdoverse/dsh-inline-media-viewer (1.0.12), which displays generated images inline below the conversation.

Core Features

Capability Description
Tool Entry After restarting DSH, image2_generate appears in the tool list
Text-to-Image / Image-to-Image Without image parameter, uses generations; with a local reference image path, uses edits (multipart upload)
Reference Image Validation Detects PNG/JPEG/WebP via magic bytes, ≤ 20 MB; reports errors before sending requests if path or format is invalid
Configuration Via the image2 settings row on the Plugins page, or editing the profile’s cordis.patch.yml
Output Boundary Default output directory imagegen-output, resolved relative to the session directory, does not escape the session directory
Visual Self-Check After saving, requires native read_image to verify the file; tool side keeps a visual acceptance TODO until completed
Conservative Default autoGenerateAssets defaults to false, so it won’t silently consume image generation quota during regular development tasks

The host README indicates testing on DeepSeek Harness 0.2.1-rc.1 and declares compatibility with 0.2.0-rc.2 and 0.1.7-rc.2; the runtime environment requires Node.js >= 22.15 (image-to-image depends on global FormData / Blob).

Installation and Activation

The official recommendation is to use the general plugin installation method (replace <profile> with your commonly used profile, e.g., web, default):

dsh plugin --profile <profile> add dsh-image2-tool

After installation, restart DSH and confirm that image2_generate is present in the tool list. If you need an independent profile, you can first export the configuration based on an existing profile, e.g.:

dsh --profile image2-demo --from-default-profile web --dump-config

The README also lists equivalent commands for installing from Release tgz, GitHub repository identifiers, or local source directories; for daily use, installing via the npm package name is sufficient. The plugin runs with the permissions and network environment of the current DSH process. Before installing, it is recommended to review the source code and the MIT license on GitHub, and independently evaluate how to manage the relay server and API keys.

Configuring the Relay Server and API Keys

GUI: Sidebar → Plugins → dsh-image2-tool → image2 row, fill in baseUrl, model, masked apiKey, and other fields.

The configuration file path is $DSH_HOME/profiles/<profile>/cordis.patch.yml; when DSH_HOME is not set, it is ~/.dsh/profiles/<profile>/cordis.patch.yml. Example snippet:

- id: image2
  name: dsh-image2-tool
  config:
    baseUrl: https://your-image-relay.example.com/v1
    model: grok-imagine-image-2.0
    apiKeyEnv: IMAGE2_API_KEY
    autoGenerateAssets: false
    outputDir: imagegen-output
    timeoutMs: 180000
    responseFormat: b64_json

The model must be a name that exists in the relay server’s GET /v1/models, otherwise it returns 404. apiKeyEnv takes the name of an environment variable; if apiKey in the settings page is non-empty, it takes priority over the environment variable. Inject the key in the terminal where you launch DSH, e.g.:

$env:IMAGE2_API_KEY = 'your-image-relay-api-key'
dsh --profile web

An already-open desktop client will not inherit newly set environment variables; you need to restart it from a terminal with the variables set. Do not commit keys to Git.

If the relay server does not accept the response_format field, set responseFormat to an empty string to omit it. If the response is a CDN temporary URL that is inaccessible locally, change responseFormat to b64_json so the image bytes are returned inline directly.

Typical Usage

Conversation Image Generation: Once the plugin is installed and configured correctly, you can directly ask the Agent to “generate an image of XXX”. With autoGenerateAssets at its default false, image generation is only triggered when you explicitly request it.

Image-to-Image (Reference Image Guidance): Pass a local image path when calling image2_generate to use POST /images/edits. Parameter example:

{
  "prompt": "Keep this character design, change to a young girl proportion, normal 7-head-tall body, no chibi version",
  "image": "imagegen-output/reference.jpg",
  "aspectRatio": "3:4",
  "filename": "result.jpg"
}

image can be relative to the session directory or an absolute path; optional size (e.g., 1024x1024) or aspectRatio (e.g., 3:4, 16:9), depending on whether the relay server accepts aspect_ratio. One request generates one image; filename conflicts are automatically resolved with appended numbers.

In the workflow, after the Agent writes via image2_generate to the session directory, the inline preview plugin renders the path, then read_image performs visual acceptance. The mermaid flow in the README summarizes it as: user request → Agent calls tool → relay server → session directory → read_image → inline preview.

Use Cases and Notes

Suitable for developers already using DSH with a self-hosted OpenAI-compatible image relay server (including API key and model name). When character consistency, art style, or color palette is needed, using a reference image for image-to-image is generally more stable than pure text descriptions.

Important notes:

  • Image-to-image requires the relay server to provide /images/edits; if only text-to-image is supported, you’ll get a 400-type error like model is required, and you need to switch relay servers or use text-to-image only.
  • When autoGenerateAssets is true, the Agent may generate bitmap images in software development scenarios after confirming that no suitable assets exist inside or outside the project; user’s direct image generation requests are not limited by this switch—it is only a tool-level guideline, not a server-side authorization gate.
  • When downloading URL-based results, the plugin does not forward the relay server key to the CDN.
  • If image2_generate is missing from the tool list, check whether the profile installed successfully, whether DSH was restarted, and whether package.json’s dsh.profile.bundles includes dsh-image2-tool. If images are not inlined, confirm that @wisdoverse/dsh-inline-media-viewer is also in bundles and restart.

The community directory SkillHub plugin page and the GitHub repository are independently indexed; the directory site has no official affiliation with DeepSeek / 幻方, and installation and configuration should follow the repository README.

Conclusion

dsh-image2-tool connects “your own image relay server + DSH tool list + inline conversation preview” into a reproducible pipeline: one-line installation, configure baseUrl and model, restart, and you can use image2_generate for text-to-image and image-to-image. For more parameters, FAQ, and compatibility notes, see the GitHub README; for the community introduction page, see SkillHub: 544244857/dsh-image2-plugin.

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

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

Xiaoye