dsh-imagegen: Image Generation Plugin for DSH

Model calls in DSH typically follow the chat protocol. The guaihub provider uses api: anthropic-messages; even if an image model is declared, it only returns text. The relay station itself has a POST /v1/images/generations interface. This plugin calls that interface directly, utilizing the same backend as the web version of Studio.

Plugin Positioning

dsh-imagegen is a model inference plugin maintained by dong2007-png. It directly calls the OpenAI-style interface of the New API relay station (such as guaihub) to generate images. It supports displaying images in conversation tool cards and saving them to the workspace.

Core Capabilities

The plugin provides the following tools:

  1. generate_image: Text-to-image generation. Supported parameters include prompt, model, size, n, quality, background, and save_path.
  2. list_image_models: Filters available image model names from the GET /v1/models interface.

Installation

Install the local bundle using the plugin manager:

plugin_manager(action="install_bundle", target="file:<your local clone path>/dsh-imagegen")

After installation, dependencies are written to ~/.dsh/profiles/desktop/package.json, the bundle is appended to dsh.profile.bundles, and the package entity is placed in ~/.dsh/profiles/desktop/node_modules/dsh-imagegen, supporting hot loading.

Configuration

The default configuration points to the guaihub relay station. Keys are resolved via the DSH credentials service (process env → provider managed storage → .env).

Configuration can be overridden in the DSH plugin configuration interface or cordis.patch.yml:

- id: dsh-imagegen
  config:
    defaultModel: gpt-image-2.5-flare
    outputDir: images/gen

Configuration item descriptions:

  • baseURL: Relay station address (default: https://guaihub.com).
  • apiKeyEnv: Key name (default: GUAIHUB_API_KEY).
  • defaultModel: Default image model (default: gpt-image-2).
  • defaultSize: Default size (default: 1024x1024).
  • outputDir: Disk save directory (relative to the session working directory, default: images).
  • saveFiles: Whether to write to disk (default: true).
  • timeoutMs: Request timeout (default: 300000).

Typical Usage

Call the generate_image tool directly within a DSH conversation. You can also use the CLI script cli/gen.mjs included in the repository:

node $cli -p "A cyberpunk cat, neon rainy night" -o images/cat.png
node $cli --list
node $cli --edit in.png -p "Change the background to the seaside"

Notes

  1. File System Permissions: Writing to disk uses node:fs within the host process, bypassing DSH’s fs sandbox and file version observation.
  2. Dependency Handling: pnpm copies file: dependencies instead of creating symbolic links.
  3. Update Sync: After modifying the source code, you need to run install_bundle again for ~/dsh/dsh-imagegen, or manually copy lib/index.js to ~/.dsh/profiles/desktop/node_modules/dsh-imagegen/lib/.
  4. Network Issues: Direct connections to github.com releases/raw may fail in certain networks; third-party mirrors can be used instead.

License

Released under the MIT License.

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

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

Xiaoye