In the DeepSeek Harness (DSH) ecosystem, extending capabilities through plugins is a core design philosophy. When developing agents that require image output, asynchronous API calls, backend storage, or complex file management are often involved. This plugin is designed to integrate image generation capabilities directly into the conversation flow as a tool, wrap image generation requests into synchronous operations through an OpenAI-compatible interface, and write the results directly into the workspace.

Plugin Positioning

This is a DeepSeek Harness plugin maintained by tuofangzhe. It exposes an OpenAI-compatible generate_image tool, wraps image generation requests into synchronous operations, writes the generated image directly into the workspace of the current session, and stores attachment references for use in subsequent conversations.

Core Features

  1. OpenAI-compatible tool: Provides a standard generate_image tool interface.
  2. Synchronous request handling: Sends synchronous POST requests to the configured image generation endpoint.
  3. Workspace writing: Writes the returned image directly into the current session’s workspace, making it easy for the model to inspect.
  4. Attachment references: Stores attachment references so that models supporting image input can view the generated results.
  5. Multi-provider support: Supports configuring multiple providers (such as OpenAI and Gateway), and allows specifying which provider to use during tool invocation.
  6. Strict validation: Strictly validates file names and paths to ensure security.
  7. Exclusive writing: File creation uses exclusive wx semantics, meaning existing files are not overwritten.

Installation and Activation

The plugin must be installed into the designated DSH configuration file using the official command.

Installation

dsh plugin --profile web add @dopilot/dsh-plugin-image-gen

Activation and Configuration

After installation, the plugin inserts a line named dopilot-image-gen into the configuration file. To enable the functionality, you must override this line in cordis.patch.yml under the same configuration.

Configuration notes:
* The config field is a complete replacement, not a deep merge. When modifying it, you must rewrite all required keys.
* The providers field is required; otherwise, the plugin remains dormant and does not register any tool.
* apiKeyEnv is the credential reference name (for example, OPENAI_IMAGE_API_KEY), not the actual key. DSH resolves it through the credential service.

Example configuration (cordis.patch.yml):

- id: dopilot-image-gen
  config:
    providers:
      openai:
        baseURL: https://api.openai.com/v1
        apiKeyEnv: OPENAI_IMAGE_API_KEY
        defaultModel: gpt-image-1
        models: [gpt-image-1]
        responseFormat: png
        timeoutMs: 120000
    defaultProvider: openai
    maxImagesPerCall: 4
    outputDir: generated-images

Typical Usage

Tool Invocation

In a DSH session, the model can invoke the generate_image tool. The parameters must include prompt and output_paths.

Invocation example:

{
  "prompt": "A red circle centered on a clean white background",
  "provider": "openai",
  "size": "1024x1024",
  "output_paths": ["generated-images/red-circle-1.png"]
}

File Naming Rules

The paths in output_paths must be relative to outputDir. File names must consist of ASCII letters, digits, underscores, or hyphens, and must end with the correct extension. Supported formats are determined by the provider’s responseFormat (png, jpeg, and webp).

Provider Configuration

It supports configuring multiple providers, and the provider can be specified at invocation time via the provider parameter. apiKeyEnv is optional and can be omitted for gateways that do not require authentication.

Multi-provider example:

- id: dopilot-image-gen
  config:
    providers:
      openai:
        baseURL: https://api.openai.com/v1
        apiKeyEnv: OPENAI_IMAGE_API_KEY
        defaultModel: gpt-image-1
      gateway:
        baseURL: https://images.example.com/openai/v1
        # gateway 不需要 apiKeyEnv
        defaultModel: organization/image-model
    defaultProvider: openai

Applicable Scenarios and Notes

Applicable Scenarios

It is suitable for scenarios that require generating images directly within a DSH workflow and having the model see the results, such as generating UI component diagrams, data visualization charts, and so on.

Cautions

  1. Environment dependencies: The plugin supports ESM modules only and requires Node.js 22.19 or later.
  2. Dormant state: If providers is not configured in config, the plugin remains dormant and does not register any tool.
  3. File overwriting: Due to the wx semantics, attempting to generate a file with an existing name fails and does not overwrite the original file.
  4. Format limitations: responseFormat supports only png, jpeg, and webp; the plugin does not transcode the format returned by the provider.

Summary

This plugin simplifies the integration of image generation in DeepSeek Harness by providing an OpenAI-compatible interface. It transforms asynchronous image generation into synchronous tool calls and automatically handles file writing and attachment references, reducing development complexity.