baoyu-imagine
Original:🇺🇸 English
Not Translated
23 scriptsChecked / no sensitive code detected
AI image generation with OpenAI, Azure OpenAI, Google, OpenRouter, DashScope, MiniMax, Jimeng, Seedream, Replicate, and Tuzi APIs. Supports text-to-image, reference images, Tuzi single-video generation, aspect ratios, and batch generation from saved prompt files. Sequential by default; use batch parallel generation when the user already has multiple prompts or wants stable multi-image throughput. Use when user asks to generate, create, draw, or produce AI images and short videos.
2installs
Sourcelvgj-stack/baoyu-skills
Added on
NPX Install
npx skill4agent add lvgj-stack/baoyu-skills baoyu-imagineSKILL.md Content
Image Generation (AI SDK)
Official API-based image generation. Supports OpenAI, Azure OpenAI, Google, OpenRouter, DashScope (阿里通义万象), MiniMax, Jimeng (即梦), Seedream (豆包), Replicate, and Tuzi providers. Tuzi additionally supports single-video generation through the same CLI.
Script Directory
Agent Execution:
- = this SKILL.md file's directory
{baseDir} - Script path =
{baseDir}/scripts/main.ts - Resolve runtime: if
${BUN_X}installed →bun; ifbunavailable →npx; else suggest installing bunnpx -y bun
Step 0: Load Preferences ⛔ BLOCKING
CRITICAL: This step MUST complete BEFORE any image generation. Do NOT skip or defer.
Check EXTEND.md existence (priority: project → user):
bash
# macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/baoyu-imagine/EXTEND.md && echo "project"
test -f "${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-imagine/EXTEND.md" && echo "xdg"
test -f "$HOME/.baoyu-skills/baoyu-imagine/EXTEND.md" && echo "user"powershell
# PowerShell (Windows)
if (Test-Path .baoyu-skills/baoyu-imagine/EXTEND.md) { "project" }
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { "$HOME/.config" }
if (Test-Path "$xdg/baoyu-skills/baoyu-imagine/EXTEND.md") { "xdg" }
if (Test-Path "$HOME/.baoyu-skills/baoyu-imagine/EXTEND.md") { "user" }| Result | Action |
|---|---|
| Found | Load, parse, apply settings. If |
| Not found | ⛔ Run first-time setup (references/config/first-time-setup.md) → Save EXTEND.md → Then continue |
CRITICAL: If not found, complete the full setup (provider + model + quality + save location) using AskUserQuestion BEFORE generating any images. Generation is BLOCKED until EXTEND.md is created.
| Path | Location |
|---|---|
| Project directory |
| User home |
Legacy compatibility: if exists and the new path does not, runtime renames it to . If both files exist, runtime leaves them unchanged and uses the new path.
.baoyu-skills/baoyu-image-gen/EXTEND.mdbaoyu-imagineEXTEND.md Supports: Default provider | Default quality | Default aspect ratio | Default image size | Default models | Batch worker cap | Provider-specific batch limits
Schema:
references/config/preferences-schema.mdUsage
bash
# Basic
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cat" --image cat.png
# With aspect ratio
${BUN_X} {baseDir}/scripts/main.ts --prompt "A landscape" --image out.png --ar 16:9
# High quality
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cat" --image out.png --quality 2k
# From prompt files
${BUN_X} {baseDir}/scripts/main.ts --promptfiles system.md content.md --image out.png
# With reference images (Google, OpenAI, Azure OpenAI, OpenRouter, Replicate, MiniMax, or Seedream 4.0/4.5/5.0)
${BUN_X} {baseDir}/scripts/main.ts --prompt "Make blue" --image out.png --ref source.png
# With reference images (explicit provider/model)
${BUN_X} {baseDir}/scripts/main.ts --prompt "Make blue" --image out.png --provider google --model gemini-3-pro-image-preview --ref source.png
# Azure OpenAI (model means deployment name)
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cat" --image out.png --provider azure --model gpt-image-1.5
# OpenRouter (recommended default model)
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cat" --image out.png --provider openrouter
# OpenRouter with reference images
${BUN_X} {baseDir}/scripts/main.ts --prompt "Make blue" --image out.png --provider openrouter --model google/gemini-3.1-flash-image-preview --ref source.png
# Specific provider
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cat" --image out.png --provider openai
# DashScope (阿里通义万象)
${BUN_X} {baseDir}/scripts/main.ts --prompt "一只可爱的猫" --image out.png --provider dashscope
# DashScope Qwen-Image 2.0 Pro (recommended for custom sizes and text rendering)
${BUN_X} {baseDir}/scripts/main.ts --prompt "为咖啡品牌设计一张 21:9 横幅海报,包含清晰中文标题" --image out.png --provider dashscope --model qwen-image-2.0-pro --size 2048x872
# DashScope legacy Qwen fixed-size model
${BUN_X} {baseDir}/scripts/main.ts --prompt "一张电影感海报" --image out.png --provider dashscope --model qwen-image-max --size 1664x928
# MiniMax
${BUN_X} {baseDir}/scripts/main.ts --prompt "A fashion editorial portrait by a bright studio window" --image out.jpg --provider minimax
# MiniMax with subject reference (best for character/portrait consistency)
${BUN_X} {baseDir}/scripts/main.ts --prompt "A girl stands by the library window, cinematic lighting" --image out.jpg --provider minimax --model image-01 --ref portrait.png --ar 16:9
# MiniMax with custom size (documented for image-01)
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cinematic poster" --image out.jpg --provider minimax --model image-01 --size 1536x1024
# Replicate (google/nano-banana-pro)
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cat" --image out.png --provider replicate
# Replicate with specific model
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cat" --image out.png --provider replicate --model google/nano-banana
# Tuzi image generation via OpenAI-compatible images API
${BUN_X} {baseDir}/scripts/main.ts --prompt "A fox in neon rain" --image out.png --provider tuzi --model gpt-image-1
# Tuzi OpenRouter-style image generation with reference image
${BUN_X} {baseDir}/scripts/main.ts --prompt "Turn this into a cinematic poster" --image out.png --provider tuzi --model openrouter/google/gemini-2.5-flash-image --ref source.png
# Tuzi text-to-video
${BUN_X} {baseDir}/scripts/main.ts --prompt "A paper plane glides over the city at dawn" --video out.mp4 --provider tuzi --videoModel openrouter/google/veo-3
# Tuzi image-to-video
${BUN_X} {baseDir}/scripts/main.ts --prompt "Animate this still with slow cinematic motion" --video out.mp4 --provider tuzi --videoModel openrouter/google/veo-3 --ref source.png
# Batch mode with saved prompt files
${BUN_X} {baseDir}/scripts/main.ts --batchfile batch.json
# Batch mode with explicit worker count
${BUN_X} {baseDir}/scripts/main.ts --batchfile batch.json --jobs 4 --jsonBatch File Format
json
{
"jobs": 4,
"tasks": [
{
"id": "hero",
"promptFiles": ["prompts/hero.md"],
"image": "out/hero.png",
"provider": "replicate",
"model": "google/nano-banana-pro",
"ar": "16:9",
"quality": "2k"
},
{
"id": "diagram",
"promptFiles": ["prompts/diagram.md"],
"image": "out/diagram.png",
"ref": ["references/original.png"]
}
]
}Paths in , , and are resolved relative to the batch file's directory. is optional (overridden by CLI ). Top-level array format (without wrapper) is also accepted.
promptFilesimagerefjobs--jobsjobsOptions
| Option | Description |
|---|---|
| Prompt text |
| Read prompt from files (concatenated) |
| Output image path (required in single-image mode) |
| Output video path. Enables Tuzi single-video mode; batch video is not supported in this version |
| JSON batch file for multi-image generation |
| Worker count for batch mode (default: auto, max from config, built-in default 10) |
| Force provider (default: auto-detect) |
| Image model ID (Google: |
| Video model ID for Tuzi video generation. If omitted, falls back to |
| Aspect ratio (e.g., |
| Size (e.g., |
| Quality preset (default: |
| Image size for Google/OpenRouter (default: from quality) |
| Reference images. Supported by Google multimodal, OpenAI GPT Image edits, Azure OpenAI edits (PNG/JPG only), OpenRouter multimodal models, Replicate, MiniMax subject-reference, Seedream 5.0/4.5/4.0, and Tuzi OpenRouter-style image/video workflows |
| Video duration for Tuzi video generation |
| Video FPS for Tuzi video generation |
| Number of images |
| JSON output |
Environment Variables
| Variable | Description |
|---|---|
| OpenAI API key |
| Azure OpenAI API key |
| OpenRouter API key |
| Google API key |
| DashScope API key (阿里云) |
| MiniMax API key |
| Replicate API token |
| Jimeng (即梦) Volcengine access key |
| Jimeng (即梦) Volcengine secret key |
| Seedream (豆包) Volcengine ARK API key |
| OpenAI model override |
| Azure default deployment name |
| Backward-compatible alias for Azure default deployment/model name |
| OpenRouter model override (default: |
| Google model override |
| DashScope model override (default: |
| MiniMax model override (default: |
| Replicate model override (default: google/nano-banana-pro) |
| Jimeng model override (default: jimeng_t2i_v40) |
| Seedream model override (default: doubao-seedream-5-0-260128) |
| Tuzi API key |
| Tuzi base URL (default: |
| Tuzi image model override |
| Tuzi video model override |
| Custom OpenAI endpoint |
| Azure resource endpoint or deployment endpoint |
| Azure image API version (default: |
| Custom OpenRouter endpoint (default: |
| Optional app/site URL for OpenRouter attribution |
| Optional app name for OpenRouter attribution |
| Custom Google endpoint |
| Custom DashScope endpoint |
| Custom MiniMax endpoint (default: |
| Custom Replicate endpoint |
| Custom Jimeng endpoint (default: |
| Jimeng region (default: |
| Custom Seedream endpoint (default: |
| Override batch worker cap |
| Override provider concurrency, e.g. |
| Override provider start gap, e.g. |
Load Priority: CLI args > EXTEND.md > env vars > >
<cwd>/.baoyu-skills/.env~/.baoyu-skills/.envModel Resolution
Model priority (highest → lowest), applies to all providers:
- CLI flag:
--model <id> - EXTEND.md:
default_model.[provider] - Env var: (e.g.,
<PROVIDER>_IMAGE_MODEL)GOOGLE_IMAGE_MODEL - Built-in default
For Azure, / should be the Azure deployment name. is the preferred env var, and remains as a backward-compatible alias.
--modeldefault_model.azureAZURE_OPENAI_DEPLOYMENTAZURE_OPENAI_IMAGE_MODELEXTEND.md overrides env vars. If both EXTEND.md and env var exist, EXTEND.md wins.
default_model.google: "gemini-3-pro-image-preview"GOOGLE_IMAGE_MODEL=gemini-3.1-flash-image-previewAgent MUST display model info before each generation:
- Show:
Using [provider] / [model] - Show switch hint:
Switch model: --model <id> | EXTEND.md default_model.[provider] | env <PROVIDER>_IMAGE_MODEL
DashScope Models
Use or set / when the user wants official Qwen-Image behavior.
--model qwen-image-2.0-prodefault_model.dashscopeDASHSCOPE_IMAGE_MODELOfficial DashScope model families:
- ,
qwen-image-2.0-pro,qwen-image-2.0-pro-2026-03-03,qwen-image-2.0qwen-image-2.0-2026-03-03- Free-form in
sizeformat宽*高 - Total pixels must stay between and
512*5122048*2048 - Default size is approximately
1024*1024 - Best choice for custom ratios such as and text-heavy Chinese/English layouts
21:9
- Free-form
- ,
qwen-image-max,qwen-image-max-2025-12-30,qwen-image-plus,qwen-image-plus-2026-01-09qwen-image- Fixed sizes only: ,
1664*928,1472*1104,1328*1328,1104*1472928*1664 - Default size is
1664*928 - currently has the same capability as
qwen-imageqwen-image-plus
- Fixed sizes only:
- Legacy DashScope models such as ,
z-image-turbo,z-image-ultrawanx-v1- Keep using them only when the user explicitly asks for legacy behavior or compatibility
When translating CLI args into DashScope behavior:
- wins over
--size--ar - For , prefer explicit
qwen-image-2.0*; otherwise infer from--sizeand use the official recommended resolutions below--ar - For , only use the five official fixed sizes; if the requested ratio is not covered, switch to
qwen-image-max/plus/imageqwen-image-2.0-pro - is a baoyu-imagine compatibility preset, not a native DashScope API field. Mapping
--quality/normalonto the2ktable below is an implementation inference, not an official API guaranteeqwen-image-2.0*
Recommended sizes for common aspect ratios:
qwen-image-2.0*| Ratio | | |
|---|---|---|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
DashScope official APIs also expose , , and , but does not expose them as dedicated CLI flags today.
negative_promptprompt_extendwatermarkbaoyu-imagineOfficial references:
MiniMax Models
Use or set / when the user wants MiniMax image generation.
--model image-01default_model.minimaxMINIMAX_IMAGE_MODELOfficial MiniMax image model options currently documented in the API reference:
- (recommended default)
image-01- Supports text-to-image and subject-reference image generation
- Supports official values:
aspect_ratio,1:1,16:9,4:3,3:2,2:3,3:4,9:1621:9 - Supports documented custom /
widthoutput sizes when usingheight--size <WxH> - and
widthmust both be betweenheightand512, and both must be divisible by20488
image-01-live- Lower-latency variant
- Use for sizing; MiniMax documents custom
--ar/widthas only effective forheightimage-01
MiniMax subject reference notes:
- files are sent as MiniMax
--refsubject_reference - MiniMax docs currently describe as
subject_reference[].typecharacter - Official docs say supports public URLs or Base64 Data URLs;
image_filesends local refs as Data URLsbaoyu-imagine - Official docs recommend front-facing portrait references in JPG/JPEG/PNG under 10MB
Official references:
OpenRouter Models
Use full OpenRouter model IDs, e.g.:
- (recommended, supports image output and reference-image workflows)
google/gemini-3.1-flash-image-preview google/gemini-2.5-flash-image-previewblack-forest-labs/flux.2-pro- Other OpenRouter image-capable model IDs
Notes:
- OpenRouter image generation uses , not the OpenAI
/chat/completionsendpoints/images - If is used, choose a multimodal model that supports image input and image output
--ref - maps to OpenRouter
--imageSize;imageGenerationOptions.sizeis converted to the nearest OpenRouter size and inferred aspect ratio when possible--size <WxH>
Tuzi Models
Tuzi is a universal model proxy — like OpenRouter, it routes to any supported model. Use full model IDs, e.g.:
- (default, fast and capable)
gemini-3.1-flash-image-preview - (OpenAI-compatible images API)
gpt-image-1 - (OpenRouter-style routing with reference-image support)
openrouter/google/gemini-2.5-flash-image openrouter/google/gemini-3.1-flash-image-preview- Other OpenAI-compatible or OpenRouter-style image model IDs
Notes:
- Standard model IDs (e.g. ) use the
gpt-image-1endpoint/images/generations - OpenRouter-style IDs (containing ) and any task with
/automatically switch to--ref/chat/completions - Tuzi supports for all OpenRouter-style models that accept image input
--ref - Video generation uses with
/chat/completions(e.g.--videoModel)openrouter/google/veo-3
Replicate Models
Supported model formats:
- (recommended for official models), e.g.
owner/namegoogle/nano-banana-pro - (community models by version), e.g.
owner/name:versionstability-ai/sdxl:<version>
Examples:
bash
# Use Replicate default model
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cat" --image out.png --provider replicate
# Override model explicitly
${BUN_X} {baseDir}/scripts/main.ts --prompt "A cat" --image out.png --provider replicate --model google/nano-bananaProvider Selection
- provided + no
--ref→ auto-select Google first, then OpenAI, then Azure, then OpenRouter, then Replicate, then Seedream, then MiniMax, then Tuzi (MiniMax subject reference is more specialized toward character/portrait consistency)--provider - specified → use it (if
--provider, must be--ref,google,openai,azure,openrouter,replicate,seedream, orminimax)tuzi - Only one API key available → use that provider
- Multiple available → default to Google
Quality Presets
| Preset | Google imageSize | OpenAI Size | OpenRouter size | Replicate resolution | Use Case |
|---|---|---|---|---|---|
| 1K | 1024px | 1K | 1K | Quick previews |
| 2K | 2048px | 2K | 2K | Covers, illustrations, infographics |
Google/OpenRouter imageSize: Can be overridden with
--imageSize 1K|2K|4KAspect Ratios
Supported: , , , , ,
1:116:99:164:33:42.35:1- Google multimodal: uses
imageConfig.aspectRatio - OpenAI: maps to closest supported size
- OpenRouter: sends ; if only
imageGenerationOptions.aspect_ratiois given, aspect ratio is inferred automatically--size <WxH> - Replicate: passes to model; when
aspect_ratiois provided without--ref, defaults to--armatch_input_image - MiniMax: sends official values directly; if
aspect_ratiois given without--size <WxH>,--ar/widthare sent forheightimage-01
Generation Mode
Default: Sequential generation.
Batch Parallel Generation: When contains 2 or more pending tasks, the script automatically enables parallel generation.
--batchfile| Mode | When to Use |
|---|---|
| Sequential (default) | Normal usage, single images, small batches |
| Parallel batch | Batch mode with 2+ tasks |
Execution choice:
| Situation | Preferred approach | Why |
|---|---|---|
| One image, or 1-2 simple images | Sequential | Lower coordination overhead and easier debugging |
| Multiple images already have saved prompt files | Batch ( | Reuses finalized prompts, applies shared throttling/retries, and gives predictable throughput |
| Each image still needs separate reasoning, prompt writing, or style exploration | Subagents | The work is still exploratory, so each image may need independent analysis before generation |
Output comes from | Batch ( | That workflow already produces prompt files, so direct batch execution is the intended path |
Rule of thumb:
- Prefer batch over subagents once prompt files are already saved and the task is "generate all of these"
- Use subagents only when generation is coupled with per-image thinking, rewriting, or divergent creative exploration
Parallel behavior:
- Default worker count is automatic, capped by config, built-in default 10
- Provider-specific throttling is applied only in batch mode, and the built-in defaults are tuned for faster throughput while still avoiding obvious RPM bursts
- You can override worker count with
--jobs <count> - Each image retries automatically up to 3 attempts
- Final output includes success count, failure count, and per-image failure reasons
Error Handling
- Missing API key → error with setup instructions
- Generation failure → auto-retry up to 3 attempts per image
- Invalid aspect ratio → warning, proceed with default
- Reference images with unsupported provider/model → error with fix hint
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.