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:
generate_image: Text-to-image generation. Supported parameters include prompt, model, size, n, quality, background, and save_path.list_image_models: Filters available image model names from theGET /v1/modelsinterface.
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¶
- File System Permissions: Writing to disk uses
node:fswithin the host process, bypassing DSH’s fs sandbox and file version observation. - Dependency Handling: pnpm copies
file:dependencies instead of creating symbolic links. - Update Sync: After modifying the source code, you need to run
install_bundleagain for~/dsh/dsh-imagegen, or manually copylib/index.jsto~/.dsh/profiles/desktop/node_modules/dsh-imagegen/lib/. - Network Issues: Direct connections to
github.comreleases/raw may fail in certain networks; third-party mirrors can be used instead.
License¶
Released under the MIT License.