Generate or edit images from text prompts. Use when the user asks to create, draw, design, or edit an image, illustration, photo, icon, poster, or any visual co
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-image-generation-cd24e86084fc ,按照其中的说明把「image-generation」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Generate and edit images using AI models. The script automatically picks a backend based on which API keys are configured — you don't need to specify a model unless the user explicitly names one. Never guess or invent a model: when the user doesn't name one, omit model entirely so the configured default/provider is used.
Supported models (passed via model only when the user asks for a specific one):
gpt-image-2.5-flare (recommended default: best quality/latency trade-off), gpt-image-2.5-sunburst (highest editing precision), gpt-image-2, gpt-image-1nano-banana-2, nano-banana-pro, nano-bananaseedream-5.0-lite, seedream-4.5qwen-image-2.0, qwen-image-2.0-proimage-01Run scripts/generate.py with a JSON argument. Use the absolute <base_dir> path — do NOT cd into the skill directory, since it is a builtin skill and gets reset on restart (anything written there is lost).
python <base_dir>/scripts/generate.py '<json_args>'
Images are saved to the workspace (or the open project dir) under images/, so they persist and stay reachable to the client.
Set bash timeout to at least 600 seconds, as image generation can take 30–200s per provider, and the script may try multiple providers sequentially. Call it synchronously (do not run it in the background) and wait for its output in the same turn.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | yes | — | Image description |
image_url | string / list | no | null | Input image(s) for editing: local file path or URL. Multi-image fusion is supported (pass a list) |
quality | string | no | auto | low / medium / high (only some backends honour this) |
size | string | no | auto | 512 / 1K / 2K / 3K / 4K, or pixel value (1024x1024) |
aspect_ratio | string | no | null | 1:1 / 3:2 / 2:3 / 16:9 / 9:16 / 21:9 (some backends also support extreme ratios like 1:4 / 8:1) |
Higher quality and larger size cost more and run slower. In normal cases, when the user does not explicitly specify, low or medium is sufficient. Only use high when the user asks for it.
python <base_dir>/scripts/generate.py '{"prompt": "A corgi astronaut floating in space"}'
With aspect ratio:
python <base_dir>/scripts/generate.py '{"prompt": "Isometric miniature city of Shanghai at sunset", "size": "2K", "aspect_ratio": "16:9"}'
When the user asks to edit, modify, or improve an existing image, pass the original image via image_url. Prefer local file paths directly — the script handles file reading internally. Without image_url, the script generates a brand-new image instead of editing.
python <base_dir>/scripts/generate.py '{"prompt": "Add a Santa hat to the dog", "image_url": "/path/to/dog.png"}'
Multi-image fusion — pass a list:
python <base_dir>/scripts/generate.py '{"prompt": "Combine these characters into a group photo", "image_url": ["/path/a.png", "/path/b.png"]}'
Prints JSON to stdout:
{
"model": "doubao-seedream-5-0-260128",
"images": [
{"url": "/path/to/output.png"}
]
}
After success, display the image to the user. You can either embed it in markdown () or use the send tool.
On error:
{
"error": "error message"
}
The script needs at least one of these API keys (set via env_config or config.json):
OPENAI_API_KEY / GEMINI_API_KEY / ARK_API_KEY / DASHSCOPE_API_KEY / MINIMAX_API_KEY / LINKAI_API_KEY
Each also has an optional *_API_BASE for custom endpoints. The script automatically picks the first configured backend and falls back to the next if it fails — no need to specify a model.
If the script returns an error after trying all configured backends, do NOT retry with the same parameters — the failure is almost always a configuration issue (wrong API key, unsupported API base). Tell the user to fix it via env_config, then retry.
quality / size to let the model pick automatically (auto).