---
name: generate-image
slug: generate-image
version: 0.2.0
description: Use the image models declared in local runtime config to generate new images or edit workspace references, including “换背景” and “继续修改上一张”.
category: integration
tags:
  - automation
  - integration
---

# Generate Image

Use the managed image-generation gateway to create or edit image files in the user's workspace. This is a Skill capability, not a chat-model switch.

## Workflow

1. For model questions, call `ListImageModels`, which reads the instance's local `imageGeneration` config. Use only its declared models, default order, operations, limits, and contract metadata; do not discover models through a remote `/models` request. When the user has not explicitly selected a model, use the configured default first and try later configured models in order if generation fails. Only pass `model` to `GenerateImage` when the user explicitly selected a model. Do not infer editing support from a model name or image input modality.
2. Turn the user's request into one self-contained image prompt. Preserve requested text, composition, style, colors, aspect ratio, and exclusions exactly. Ask a question only when a missing choice would materially change the result.
3. Run the bundled script from this skill's `rootDir`. The tool passes a JSON request through standard input:

   ```bash
   python3 "<rootDir>/scripts/generate_image.py" --request-file - <<'JSON'
   {"operation":"generate","prompt":"<complete image prompt>"}
   JSON
   ```

4. Use `operation: "edit"` or `"mask_edit"` with `referenceImages` paths for source edits. Use `operation: "reference"` when the model catalog explicitly declares reference generation. A generated artifact path can be passed as the next request's reference path for continuing edits; never overwrite the source.
5. Add `size`, `quality`, or `count` only when requested and validate them against the selected model's declared limits. Generate one image by default and never generate more than eight in one call.
6. Read the JSON printed by the script. On success, verify each returned `path` exists and report the requested model, actual model (or unknown), operation, and output. Xigua registers `artifacts` and shows them as chat attachments automatically. On failure, report the script's error and do not claim that an image was created.

## Rules

- Do not request or reveal API keys. The script uses the instance's managed Soul Store gateway configuration.
- Load this skill directly for image requests. Do not call `ManageSkill list` merely to check whether it exists.
- Do not replace the current chat model with the image model.
- Save output only inside the workspace. Use `--output-dir` only for a workspace-relative destination.
- Do not paste base64 image data into chat or write it manually.
- Source images are sent as image data or an explicitly supported gateway reference; a local path is never sent to the remote gateway.
- Requested and actual model identities are separate. If the gateway does not return an actual model, report it as unknown rather than copying the request model.
- A timeout does not trigger an automatic retry or model switch because the upstream may already have generated an image.
