dsh-imagegen
Codex-style image_gen and grok-build /imagine for DeepSeek Harness.
DeepSeek chat-completions is text-only, and DSH does not ship a native text-to-image API. This bundle registers:
| Surface | Mirrors | Behavior |
|---|---|---|
Model tool image_gen | Codex built-in image_gen | The agent draws on request; files land in the workspace |
Slash command /imagine <prompt> | grok-build /imagine | Generates immediately, no model turn |
The backend is OpenAI-compatible POST {baseURL}/images/generations. Shipped defaults target xAI:
https://api.x.ai/v1- credential name
XAI_API_KEY - model
grok-imagine-image-quality
Any compatible gateway works (OpenAI, OpenRouter, a local proxy). Override baseURL, apiKeyEnv, and model in the profile patch. Never put the API key in the patch file.
Install
dsh plugin --profile web add https://github.com/songlairui/dsh-imagegen/archive/refs/tags/v0.1.0.tar.gzRestart the running dsh web process. dsh --profile web --dump-config should include a # == dsh-imagegen layer.
Store the key in DSH credentials (Settings → Models) under XAI_API_KEY, or export XAI_API_KEY / OPENAI_API_KEY.
Use
> Use image_gen to draw a shiba in sunglasses as a 35mm film still, save as shiba.png
or:
/imagine a shiba in sunglasses, film still, 35mmOutputs:
- workspace
generated_images/<name>.png $DSH_HOME/generated_images/<name>.png
If the current route declares image input (for example a grok-4 vision model), the tool result also carries a durable DSH image block so the picture can render inline.
Configuration
A profile patch replaces the whole config object. Restate every field you care about in $DSH_HOME/profiles/web/cordis.patch.yml:
- id: imagegen
name: dsh-imagegen
config:
baseURL: https://api.x.ai/v1
apiKeyEnv: XAI_API_KEY
model: grok-imagine-image-quality
timeoutMs: 180000
outputDir: generated_imagesOpenAI Images:
baseURL: https://api.openai.com/v1
apiKeyEnv: OPENAI_API_KEY
model: gpt-image-2Any other OpenAI-compatible images/generations endpoint: set baseURL to that origin plus /v1, and apiKeyEnv to the credential name you stored in DSH.
Tool parameters
image_gen(prompt, file_name?, model?, size?, quality?, reference_image?)
promptrequiredfile_namee.g.hero.pngmodeloverrides the defaultsize1024x1024/1536x1024/2K/autoqualitygpt-image only:low/medium/high/autoreference_imagelocal path, data URL, or https URL
Key resolution
1. ctx.credentials.resolve(apiKeyEnv) 2. Environment variables XAI_API_KEY / OPENAI_API_KEY / OPENROUTER_API_KEY 3. A non-expired xAI key in ~/.grok/auth.json (grok CLI cache), if present