[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EBQEVH9C7M31WC1YA7F443":3,"skill-same:01M7EBQEVH9C7M31WC1YA7F443":103},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":35,"repositoryHtmlUrl":36,"repositoryHomepageUrl":6,"ownerHtmlUrl":37,"ownerBlogUrl":6,"ownerDescription":38,"updatedAt":39,"install":40,"resources":52},"01M7EBQEVH9C7M31WC1YA7F443","baoyu-image-gen",null,"AI image generation with OpenAI GPT Image 2.5, Azure OpenAI, Google, OpenRouter, DashScope, Z.AI GLM-Image, MiniMax, Jimeng, Seedream, Replicate and Agnes APIs. Supports text-to-image, reference images, 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, or draw images.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: baoyu-image-gen\ndescription: AI image generation with OpenAI GPT Image 2.5, Azure OpenAI, Google, OpenRouter, DashScope, Z.AI GLM-Image, MiniMax, Jimeng, Seedream, Replicate and Agnes APIs. Supports text-to-image, reference images, 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, or draw images.\nversion: 2.2.0\nmetadata:\n  openclaw:\n    homepage: https:\u002F\u002Fgithub.com\u002FJimLiu\u002Fbaoyu-skills#baoyu-image-gen\n    requires:\n      anyBins:\n        - bun\n        - npx\n---\n\n# Image Generation (AI SDK)\n\nOfficial API-based image generation. Supports OpenAI GPT Image 2.5, Azure OpenAI, Google, OpenRouter, DashScope (阿里通义万象), Z.AI GLM-Image, MiniMax, Jimeng (即梦), Seedream (豆包), Replicate and Agnes.\n\n## User Input Tools\n\nWhen this skill prompts the user, follow this tool-selection rule (priority order):\n\n1. **Prefer built-in user-input tools** exposed by the current agent runtime — e.g., `AskUserQuestion`, `request_user_input`, `clarify`, `ask_user`, or any equivalent.\n2. **Fallback**: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number\u002Fanswer for each question.\n3. **Batching**: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order.\n\nConcrete `AskUserQuestion` references below are examples — substitute the local equivalent in other runtimes.\n\n## Script Directory\n\n`{baseDir}` = this SKILL.md's directory. All `scripts\u002F...` paths below are relative to `{baseDir}`. Main script: `{baseDir}\u002Fscripts\u002Fmain.ts`. Batch payload helper: `{baseDir}\u002Fscripts\u002Fbuild-batch.ts`. Resolve `${BUN_X}`: prefer `bun`; else `npx -y bun`; else suggest `brew install oven-sh\u002Fbun\u002Fbun`.\n\n## Step 0: Load Preferences ⛔ BLOCKING\n\nThis step MUST complete before any image generation — generation is blocked until EXTEND.md exists.\n\nCheck these paths in order; first hit wins:\n\n| Path | Scope |\n|------|-------|\n| `.baoyu-skills\u002Fbaoyu-image-gen\u002FEXTEND.md` | Project |\n| `${XDG_CONFIG_HOME:-$HOME\u002F.config}\u002Fbaoyu-skills\u002Fbaoyu-image-gen\u002FEXTEND.md` | XDG |\n| `$HOME\u002F.baoyu-skills\u002Fbaoyu-image-gen\u002FEXTEND.md` | User home |\n\n- **Found** → load, parse, apply. If `default_model.[provider]` is null → ask model only.\n- **Not found** → run first-time setup (`references\u002Fconfig\u002Ffirst-time-setup.md`) using AskUserQuestion to collect provider + model + quality + save location. Save EXTEND.md, then continue. Do not generate images before this completes.\n\nLegacy compatibility: if `.baoyu-skills\u002Fbaoyu-imagine\u002FEXTEND.md` exists and the new path doesn't, the runtime renames it to `baoyu-image-gen`. If both exist, the runtime leaves them alone and uses the new path.\n\n**EXTEND.md keys**: default provider, default quality, default aspect ratio, default image size, OpenAI image API dialect, default models, batch worker cap, provider-specific batch limits. Schema: `references\u002Fconfig\u002Fpreferences-schema.md`.\n\n## Usage\n\nMinimum working examples — see `references\u002Fusage-examples.md` for the full set including per-provider invocations and batch mode.\n\n### Identity-preserving reference prompts\n\nWhen the user wants a real person\u002Fcharacter\u002Fobject preserved from reference images, do **not** replace the reference with a long generic description. Prefer short, hard identity-preservation language:\n\n- \"Use the person\u002Fobject in the reference image(s) as the same identity. Do not redesign it or create a similar-looking new subject.\"\n- \"Only change scene, clothing, pose, lighting, rendering style, and composition. Keep the face\u002Fproportions\u002Fhair\u002Fkey accessories\u002Foverall identity from the references.\"\n- If using multiple references, state that they are the same subject and should jointly define identity.\n\nPitfall: long descriptions like \"young East Asian woman, oval face, clear eyes...\" can cause the model to synthesize a new person matching the description instead of preserving the referenced person.\n\n```bash\n# Basic\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A cat\" --image cat.png\n\n# With aspect ratio and high quality\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A landscape\" --image out.png --ar 16:9 --quality 2k\n\n# Prompt from files\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --promptfiles system.md content.md --image out.png\n\n# With reference image\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"Make blue\" --image out.png --ref source.png\n\n# Specific provider\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A cat\" --image out.png --provider dashscope --model qwen-image-2.0-pro\n\n# OpenAI GPT Image 2\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A cat\" --image out.png --provider openai --model gpt-image-2.5-flare\n\n# Codex CLI (uses logged-in Codex subscription — no OPENAI_API_KEY required; requires `codex` on PATH)\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A cat\" --image out.png --provider codex-cli --ar 16:9\n\n# Batch mode\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --batchfile batch.json --jobs 4\n\n# Build a batch file from outline.md + prompts\u002F (e.g. baoyu-article-illustrator output)\n${BUN_X} {baseDir}\u002Fscripts\u002Fbuild-batch.ts --outline outline.md --prompts prompts --output batch.json --images-dir attachments\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --batchfile batch.json --jobs 4\n```\n\n## Reference-Image Identity Preservation\n\nWhen the user wants a person\u002Fobject preserved from reference images:\n\n- Prefer a small curated set of existing source references (usually 2–4) over many images; large multi-megabyte refs can destabilize streaming providers.\n- Make the prompt say the references are the same subject and the output must use that identity. Avoid long generic facial-feature descriptions that can cause the model to synthesize a new similar-looking person.\n- Do not use newly generated outputs as references unless the user explicitly asks; generated refs compound drift.\n- If results become too polished or influencer-like, reduce stylized refs and add explicit anti-beautification constraints (no face slimming, eye enlargement, heavy makeup, commercial travel shoot, over-smoothing).\n- If the subject should look younger\u002Folder, preserve the face and express age through clothing, posture, scene, and styling; do not ask the model to change facial identity.\n\n## Options\n\n| Option | Description |\n|--------|-------------|\n| `--prompt \u003Ctext>`, `-p` | Prompt text |\n| `--promptfiles \u003Cfiles...>` | Read prompt from files (concatenated) |\n| `--image \u003Cpath>` | Output image path (required in single-image mode) |\n| `--batchfile \u003Cpath>` | JSON batch file for multi-image generation |\n| `--jobs \u003Ccount>` | Worker count for batch mode (default: auto, max from config, built-in default 10) |\n| `--provider google\\|openai\\|azure\\|openrouter\\|dashscope\\|zai\\|minimax\\|jimeng\\|seedream\\|replicate\\|codex-cli\\|agnes` | Force provider (default: auto-detect; `codex-cli` is never auto-selected — must be pinned via CLI or EXTEND.md) |\n| `--model \u003Cid>`, `-m` | Model ID — see provider references for defaults and allowed values |\n| `--ar \u003Cratio>` | Aspect ratio (`16:9`, `1:1`, `4:3`, …) |\n| `--size \u003CWxH>` | Explicit size (e.g., `1024x1024`; for `gpt-image-2.5-*` and `gpt-image-2`, width\u002Fheight must be multiples of 16, max edge 3840px, ratio no wider than 3:1) |\n| `--quality normal\\|2k` | Quality preset (default: `2k`) |\n| `--imageSize 1K\\|2K\\|4K` | Image size for Google\u002FOpenRouter (default: from quality) |\n| `--imageApiDialect openai-native\\|ratio-metadata` | OpenAI-compatible endpoint dialect — use `ratio-metadata` for gateways that expect aspect-ratio `size` plus `metadata.resolution` |\n| `--ref \u003Cfiles...>` | Reference images. Supported by Google multimodal, OpenAI GPT Image edits, Azure OpenAI edits (PNG\u002FJPG only), OpenRouter multimodal models, Replicate supported families, MiniMax subject-reference, Seedream 5.0\u002F4.5\u002F4.0, DashScope `wan2.7-image-pro`\u002F`wan2.7-image`. Not supported by Jimeng, Seedream 3.0, SeedEdit 3.0, or any DashScope model outside the `wan2.7-image*` family |\n| `--n \u003Ccount>` | Number of images. Replicate requires `--n 1` (single-output save semantics) |\n| `--json` | JSON output |\n\n## Environment Variables\n\n| Variable | Description |\n|----------|-------------|\n| `OPENAI_API_KEY` | OpenAI API key |\n| `AZURE_OPENAI_API_KEY` | Azure OpenAI API key |\n| `OPENROUTER_API_KEY` | OpenRouter API key |\n| `GOOGLE_API_KEY` | Google API key |\n| `DASHSCOPE_API_KEY` | DashScope API key |\n| `ZAI_API_KEY` (alias `BIGMODEL_API_KEY`) | Z.AI API key |\n| `MINIMAX_API_KEY` | MiniMax API key |\n| `REPLICATE_API_TOKEN` | Replicate API token |\n| `JIMENG_ACCESS_KEY_ID`, `JIMENG_SECRET_ACCESS_KEY` | Jimeng (即梦) Volcengine credentials |\n| `ARK_API_KEY` | Seedream (豆包) Volcengine ARK API key |\n| `\u003CPROVIDER>_IMAGE_MODEL` | Per-provider model override (`OPENAI_IMAGE_MODEL`, `GOOGLE_IMAGE_MODEL`, `DASHSCOPE_IMAGE_MODEL`, `ZAI_IMAGE_MODEL`\u002F`BIGMODEL_IMAGE_MODEL`, `MINIMAX_IMAGE_MODEL`, `OPENROUTER_IMAGE_MODEL`, `REPLICATE_IMAGE_MODEL`, `JIMENG_IMAGE_MODEL`, `SEEDREAM_IMAGE_MODEL`, `AGNES_IMAGE_MODEL`) |\n| `AZURE_OPENAI_DEPLOYMENT` (alias `AZURE_OPENAI_IMAGE_MODEL`) | Azure default deployment |\n| `\u003CPROVIDER>_BASE_URL` | Per-provider endpoint override |\n| `AZURE_API_VERSION` | Azure image API version (default `2025-04-01-preview`) |\n| `JIMENG_REGION` | Jimeng region (default `cn-north-1`) |\n| `OPENAI_IMAGE_API_DIALECT` | `openai-native` \\| `ratio-metadata` |\n| `OPENROUTER_HTTP_REFERER`, `OPENROUTER_TITLE` | Optional OpenRouter attribution |\n| `BAOYU_IMAGE_GEN_MAX_WORKERS` | Override batch worker cap |\n| `BAOYU_IMAGE_GEN_\u003CPROVIDER>_CONCURRENCY` | Per-provider concurrency (e.g., `BAOYU_IMAGE_GEN_REPLICATE_CONCURRENCY`; for codex-cli use `BAOYU_IMAGE_GEN_CODEX_CLI_CONCURRENCY`) |\n| `BAOYU_IMAGE_GEN_\u003CPROVIDER>_START_INTERVAL_MS` | Per-provider start-gap |\n| `BAOYU_CODEX_IMAGEGEN_BIN` | Override the codex-imagegen wrapper path for the `codex-cli` provider (default: bundled `scripts\u002Fcodex-imagegen\u002Fmain.ts`; accepts `.ts` or legacy `.sh`\u002Fbinary) |\n| `BAOYU_CODEX_IMAGEGEN_CACHE_DIR` | Enable idempotency cache for the `codex-cli` provider (off by default) |\n| `BAOYU_CODEX_IMAGEGEN_TIMEOUT_MS` | Per-attempt `codex exec` timeout for the `codex-cli` provider (default: 300000 ms) |\n| `BAOYU_CODEX_IMAGEGEN_RETRIES` | Wrapper-side retry attempts on retryable errors for the `codex-cli` provider (default: 2) |\n| `BAOYU_CODEX_IMAGEGEN_LOG_FILE` | Append JSONL diagnostic log for the `codex-cli` provider |\n\n**Load priority**: CLI args > EXTEND.md > env vars > `\u003Ccwd>\u002F.baoyu-skills\u002F.env` > `~\u002F.baoyu-skills\u002F.env`\n\n### Codex\u002FChatGPT OAuth is not an OpenAI API key\n\n`--provider openai --model gpt-image-2.5-flare` uses the standard OpenAI Images API (`\u002Fv1\u002Fimages\u002Fgenerations` or `\u002Fv1\u002Fimages\u002Fedits`) and requires `OPENAI_API_KEY`. A Codex or ChatGPT desktop login is a different entitlement and is not a drop-in replacement for `OPENAI_API_KEY`; do not paste a Codex OAuth token into `OPENAI_API_KEY` or only set `OPENAI_BASE_URL` to a Codex backend.\n\nIf the user wants to use their Codex subscription \u002F GPT Image 2 entitlement without an OpenAI API key, route through a Codex-native backend instead of this skill's `openai` provider:\n\n- In Codex runtime: use the native `imagegen` skill\u002Ftool.\n- In non-Codex runtimes with `codex` CLI installed and logged in: use `baoyu-image-gen --provider codex-cli` (preferred — it gives you the same retry \u002F cache \u002F batch flow as every other provider). The provider spawns the bundled `scripts\u002Fcodex-imagegen\u002Fmain.ts`; the same code lives upstream at `packages\u002Fbaoyu-codex-imagegen\u002Fsrc\u002Fmain.ts` for standalone callers.\n- In Hermes runtimes with a native `image_generate` tool: use that tool as a fallback, and state whether reference images were passed directly or reconstructed from extracted traits.\n\nDo not modify the existing `openai` provider to silently consume Codex OAuth. The first-class Codex-CLI path is the dedicated `codex-cli` provider, which has its own auth (Codex login), route (`codex exec`), request shape, and tests. See `references\u002Fcodex-oauth-vs-openai-api-key.md`.\n\n## Model Resolution\n\nPriority (highest → lowest) applies to every provider:\n\n1. CLI flag `--model \u003Cid>`\n2. EXTEND.md `default_model.[provider]`\n3. Env var `\u003CPROVIDER>_IMAGE_MODEL`\n4. Built-in default\n\nFor OpenAI, the built-in default is `gpt-image-2.5-flare` (fast, lowest latency). `gpt-image-2.5-sunburst` is the most capable variant for complex scenes and precise edits; `gpt-image-2`, `gpt-image-1.5`, `gpt-image-1`, and dated GPT Image snapshots (e.g. `gpt-image-2.5-flare-2026-09-08`, `gpt-image-2-2026-04-21`) remain selectable with `--model` or `OPENAI_IMAGE_MODEL`.\n\nFor Google, the built-in default is `gemini-3-pro-image`. `gemini-3.1-flash-image` is the faster low-cost option, and `gemini-3.1-flash-lite-image` is the cheapest — it only produces 1K output, so `--quality 2k` \u002F `--imageSize 2K|4K` is clamped to 1K with a warning.\n\nFor DashScope, the built-in default is `qwen-image-2.0-pro`; `qwen-image-3.0-pro` is the newest flagship and uses the same sizing rules.\n\nFor Azure, `--model` \u002F `default_model.azure` is the Azure deployment name. `AZURE_OPENAI_DEPLOYMENT` is the preferred env var; `AZURE_OPENAI_IMAGE_MODEL` is kept as a backward-compatible alias. If your Azure deployment is named after the underlying model, use `gpt-image-2.5-flare`; otherwise use the exact custom deployment name.\n\nEXTEND.md overrides env vars: if EXTEND.md sets `default_model.google: \"gemini-3-pro-image\"` and the env var sets `GOOGLE_IMAGE_MODEL=gemini-3.1-flash-image`, EXTEND.md wins.\n\n**Display model info before each generation**:\n\n- `Using [provider] \u002F [model]`\n- `Switch model: --model \u003Cid> | EXTEND.md default_model.[provider] | env \u003CPROVIDER>_IMAGE_MODEL`\n\n## OpenAI-Compatible Gateway Dialects\n\n`provider=openai` means the auth and routing entrypoint is OpenAI-compatible. It does **not** guarantee the upstream image API uses OpenAI native semantics. When a gateway expects a different wire format, set `default_image_api_dialect` in EXTEND.md, `OPENAI_IMAGE_API_DIALECT`, or `--imageApiDialect`:\n\n- `openai-native`: pixel `size` (`1536x1024`) and native OpenAI quality fields\n- `ratio-metadata`: aspect-ratio `size` (`16:9`) plus `metadata.resolution` (`1K|2K|4K`) and `metadata.orientation`\n\nUse `openai-native` for the OpenAI native API or strict clones; try `ratio-metadata` for compatibility gateways in front of Gemini or similar models. Current limitation: `ratio-metadata` applies only to text-to-image; reference-image edits still need `openai-native` or a provider with first-class edit support.\n\n## Provider-Specific Guides\n\nEach provider has its own quirks (model families, size rules, ref support, limits). Read these when the user picks that provider or asks for non-default behavior:\n\n| Provider | Reference |\n|----------|-----------|\n| DashScope (Qwen-Image families, custom sizes) | `references\u002Fproviders\u002Fdashscope.md` |\n| Z.AI (GLM-Image, cogview-4) | `references\u002Fproviders\u002Fzai.md` |\n| MiniMax (image-01, subject-reference) | `references\u002Fproviders\u002Fminimax.md` |\n| OpenRouter (multimodal models, `\u002Fchat\u002Fcompletions` flow) | `references\u002Fproviders\u002Fopenrouter.md` |\n| Replicate (nano-banana, Seedream, Wan) | `references\u002Fproviders\u002Freplicate.md` |\n| Codex CLI (wraps bundled `scripts\u002Fcodex-imagegen\u002F`; Codex login, no `OPENAI_API_KEY`) | `references\u002Fproviders\u002Fcodex-cli.md` |\n| Agnes (agnes-image-2.1-flash, reference-image support) | `references\u002Fproviders\u002Fagnes.md` |\n\n## Provider Selection\n\n1. `--ref` provided + no `--provider` → auto-select Google → OpenAI → Azure → OpenRouter → Replicate → Seedream → MiniMax → Agnes (MiniMax's subject reference is more specialized toward character\u002Fportrait consistency)\n2. `--provider` specified → use it (if `--ref`, must be google\u002Fopenai\u002Fazure\u002Fopenrouter\u002Freplicate\u002Fseedream\u002Fminimax\u002Fcodex-cli\u002Fagnes)\n3. Only one API key present → use that provider\n4. Multiple keys → default priority: Google → OpenAI → Azure → OpenRouter → DashScope → Z.AI → MiniMax → Replicate → Jimeng → Seedream → Agnes\n5. `codex-cli` is **never auto-selected** — set `default_provider: codex-cli` in EXTEND.md or pass `--provider codex-cli`. It spawns `codex exec` via the bundled `scripts\u002Fcodex-imagegen\u002Fmain.ts` TS entrypoint (run with `bun`) and uses the user's Codex subscription (no `OPENAI_API_KEY`). Requires `codex` on `PATH` with an active `codex login`.\n\n## Quality Presets\n\n| Preset | Google imageSize | OpenAI size | OpenRouter size | Replicate resolution | Use case |\n|--------|------------------|-------------|-----------------|----------------------|----------|\n| `normal` | 1K | 1024px target | 1K | 1K | Quick previews |\n| `2k` (default) | 2K | 2048px target | 2K | 2K | Covers, illustrations, infographics |\n\nGoogle\u002FOpenRouter `imageSize` can be overridden with `--imageSize 1K|2K|4K`.\n\nFor OpenAI native `gpt-image-2.5-*` and `gpt-image-2`, `normal` maps to `quality=medium` and a low-latency valid size near the requested aspect ratio; `2k` maps to `quality=high` and 2048px-class sizes such as `2048x2048`, `2048x1152`, or `1152x2048`. Use explicit `--size` for valid custom or 4K outputs, e.g. `3840x2160`.\n\n## Aspect Ratios\n\nSupported: `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `2.35:1`.\n\n- Google multimodal: `imageConfig.aspectRatio`\n- OpenAI: `gpt-image-2.5-*` and `gpt-image-2` use the closest valid custom size for the requested ratio; older GPT Image and DALL·E models use their closest supported fixed size\n- OpenRouter: `imageGenerationOptions.aspect_ratio`; if only `--size \u003CWxH>` is given, the ratio is inferred\n- Replicate: behavior is model-specific — `google\u002Fnano-banana*` uses `aspect_ratio`, `bytedance\u002Fseedream-*` uses documented Replicate ratios, Wan 2.7 maps `--ar` to a concrete `size`\n- MiniMax: official `aspect_ratio` values; if `--size \u003CWxH>` is given without `--ar`, sends `width`\u002F`height` for `image-01`\n\n## Generation Mode\n\n**Default**: sequential. **Batch parallel**: enabled automatically when `--batchfile` contains 2+ pending tasks.\n\n| Situation | Prefer | Why |\n|-----------|--------|-----|\n| One image, or 1-2 simple images | Sequential | Lower coordination overhead, easier debugging |\n| Multiple images with saved prompt files | Batch (`--batchfile`) | Reuses finalized prompts, applies shared throttling\u002Fretries, predictable throughput |\n| Each image still needs its own reasoning \u002F prompt writing \u002F style exploration | Subagents | Work is still exploratory, each needs independent analysis |\n| Input is `outline.md` + `prompts\u002F` (e.g. from `baoyu-article-illustrator`) | Batch — use `{baseDir}\u002Fscripts\u002Fbuild-batch.ts` to assemble the payload | The outline + prompt files already contain everything needed |\n\nRule of thumb: once prompt files are saved and the task is \"generate all of these\", prefer batch over subagents. Use subagents only when generation is coupled with per-image thinking or divergent creative exploration.\n\n**Parallel behavior**:\n\n- Default worker count is automatic, capped by config, built-in default 10\n- Provider-specific throttling applies only in batch mode; defaults are tuned for throughput while avoiding RPM bursts\n- Override with `--jobs \u003Ccount>`\n- Each image retries up to 3 attempts\n- Final output includes success count, failure count, and per-image failure reasons\n\n## Error Handling\n\n- Missing API key → error with setup instructions\n- Generation failure → auto-retry up to 3 attempts per image\n- Invalid aspect ratio → warning, proceed with default\n- Reference images with unsupported provider\u002Fmodel → error with fix hint\n\n### Codex image2 fallback\n\nIf `--provider openai --model gpt-image-2.5-flare` fails because `OPENAI_API_KEY` is missing but the current runtime has a native image-generation backend or the repo-level `codex-imagegen` wrapper is available, use that path rather than leaving the user waiting. Be explicit about whether the fallback is true reference-image generation or only a text-prompt reconstruction from extracted visual traits. See `references\u002Fcodex-image2-fallback.md`.\n\n## References\n\n| File | Content |\n|------|---------|\n| `references\u002Fusage-examples.md` | Extended CLI examples across providers and batch mode |\n| `references\u002Fcodex-oauth-vs-openai-api-key.md` | Why Codex\u002FChatGPT OAuth image2 entitlement is not usable through baoyu-image-gen's standard OpenAI API-key provider |\n| `references\u002Fcodex-image2-fallback.md` | Practical fallback behavior when OpenAI API credentials are absent but Codex\u002Fnative image generation is available |\n| `references\u002Fproviders\u002Fdashscope.md` | DashScope families, sizes, limits |\n| `references\u002Fproviders\u002Fzai.md` | Z.AI GLM-image \u002F cogview-4 |\n| `references\u002Fproviders\u002Fminimax.md` | MiniMax image-01 + subject reference |\n| `references\u002Fproviders\u002Fopenrouter.md` | OpenRouter multimodal flow |\n| `references\u002Fproviders\u002Freplicate.md` | Replicate supported families + guardrails |\n| `references\u002Fproviders\u002Fagnes.md` | Agnes (agnes-image-2.1-flash) sizing, refs, and limits |\n| `references\u002Fconfig\u002Fpreferences-schema.md` | EXTEND.md schema |\n| `references\u002Fconfig\u002Ffirst-time-setup.md` | First-time setup flow |\n\n## Extension Support\n\nCustom configurations via EXTEND.md. See Step 0 for paths and schema.\n","# Image Generation (AI SDK)\n\nOfficial API-based image generation. Supports OpenAI GPT Image 2.5, Azure OpenAI, Google, OpenRouter, DashScope (阿里通义万象), Z.AI GLM-Image, MiniMax, Jimeng (即梦), Seedream (豆包), Replicate and Agnes.\n\n## User Input Tools\n\nWhen this skill prompts the user, follow this tool-selection rule (priority order):\n\n1. **Prefer built-in user-input tools** exposed by the current agent runtime — e.g., `AskUserQuestion`, `request_user_input`, `clarify`, `ask_user`, or any equivalent.\n2. **Fallback**: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number\u002Fanswer for each question.\n3. **Batching**: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order.\n\nConcrete `AskUserQuestion` references below are examples — substitute the local equivalent in other runtimes.\n\n## Script Directory\n\n`{baseDir}` = this SKILL.md's directory. All `scripts\u002F...` paths below are relative to `{baseDir}`. Main script: `{baseDir}\u002Fscripts\u002Fmain.ts`. Batch payload helper: `{baseDir}\u002Fscripts\u002Fbuild-batch.ts`. Resolve `${BUN_X}`: prefer `bun`; else `npx -y bun`; else suggest `brew install oven-sh\u002Fbun\u002Fbun`.\n\n## Step 0: Load Preferences ⛔ BLOCKING\n\nThis step MUST complete before any image generation — generation is blocked until EXTEND.md exists.\n\nCheck these paths in order; first hit wins:\n\n| Path | Scope |\n|------|-------|\n| `.baoyu-skills\u002Fbaoyu-image-gen\u002FEXTEND.md` | Project |\n| `${XDG_CONFIG_HOME:-$HOME\u002F.config}\u002Fbaoyu-skills\u002Fbaoyu-image-gen\u002FEXTEND.md` | XDG |\n| `$HOME\u002F.baoyu-skills\u002Fbaoyu-image-gen\u002FEXTEND.md` | User home |\n\n- **Found** → load, parse, apply. If `default_model.[provider]` is null → ask model only.\n- **Not found** → run first-time setup (`references\u002Fconfig\u002Ffirst-time-setup.md`) using AskUserQuestion to collect provider + model + quality + save location. Save EXTEND.md, then continue. Do not generate images before this completes.\n\nLegacy compatibility: if `.baoyu-skills\u002Fbaoyu-imagine\u002FEXTEND.md` exists and the new path doesn't, the runtime renames it to `baoyu-image-gen`. If both exist, the runtime leaves them alone and uses the new path.\n\n**EXTEND.md keys**: default provider, default quality, default aspect ratio, default image size, OpenAI image API dialect, default models, batch worker cap, provider-specific batch limits. Schema: `references\u002Fconfig\u002Fpreferences-schema.md`.\n\n## Usage\n\nMinimum working examples — see `references\u002Fusage-examples.md` for the full set including per-provider invocations and batch mode.\n\n### Identity-preserving reference prompts\n\nWhen the user wants a real person\u002Fcharacter\u002Fobject preserved from reference images, do **not** replace the reference with a long generic description. Prefer short, hard identity-preservation language:\n\n- \"Use the person\u002Fobject in the reference image(s) as the same identity. Do not redesign it or create a similar-looking new subject.\"\n- \"Only change scene, clothing, pose, lighting, rendering style, and composition. Keep the face\u002Fproportions\u002Fhair\u002Fkey accessories\u002Foverall identity from the references.\"\n- If using multiple references, state that they are the same subject and should jointly define identity.\n\nPitfall: long descriptions like \"young East Asian woman, oval face, clear eyes...\" can cause the model to synthesize a new person matching the description instead of preserving the referenced person.\n\n```bash\n# Basic\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A cat\" --image cat.png\n\n# With aspect ratio and high quality\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A landscape\" --image out.png --ar 16:9 --quality 2k\n\n# Prompt from files\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --promptfiles system.md content.md --image out.png\n\n# With reference image\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"Make blue\" --image out.png --ref source.png\n\n# Specific provider\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A cat\" --image out.png --provider dashscope --model qwen-image-2.0-pro\n\n# OpenAI GPT Image 2\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A cat\" --image out.png --provider openai --model gpt-image-2.5-flare\n\n# Codex CLI (uses logged-in Codex subscription — no OPENAI_API_KEY required; requires `codex` on PATH)\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --prompt \"A cat\" --image out.png --provider codex-cli --ar 16:9\n\n# Batch mode\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --batchfile batch.json --jobs 4\n\n# Build a batch file from outline.md + prompts\u002F (e.g. baoyu-article-illustrator output)\n${BUN_X} {baseDir}\u002Fscripts\u002Fbuild-batch.ts --outline outline.md --prompts prompts --output batch.json --images-dir attachments\n${BUN_X} {baseDir}\u002Fscripts\u002Fmain.ts --batchfile batch.json --jobs 4\n```\n\n## Reference-Image Identity Preservation\n\nWhen the user wants a person\u002Fobject preserved from reference images:\n\n- Prefer a small curated set of existing source references (usually 2–4) over many images; large multi-megabyte refs can destabilize streaming providers.\n- Make the prompt say the references are the same subject and the output must use that identity. Avoid long generic facial-feature descriptions that can cause the model to synthesize a new similar-looking person.\n- Do not use newly generated outputs as references unless the user explicitly asks; generated refs compound drift.\n- If results become too polished or influencer-like, reduce stylized refs and add explicit anti-beautification constraints (no face slimming, eye enlargement, heavy makeup, commercial travel shoot, over-smoothing).\n- If the subject should look younger\u002Folder, preserve the face and express age through clothing, posture, scene, and styling; do not ask the model to change facial identity.\n\n## Options\n\n| Option | Description |\n|--------|-------------|\n| `--prompt \u003Ctext>`, `-p` | Prompt text |\n| `--promptfiles \u003Cfiles...>` | Read prompt from files (concatenated) |\n| `--image \u003Cpath>` | Output image path (required in single-image mode) |\n| `--batchfile \u003Cpath>` | JSON batch file for multi-image generation |\n| `--jobs \u003Ccount>` | Worker count for batch mode (default: auto, max from config, built-in default 10) |\n| `--provider google\\|openai\\|azure\\|openrouter\\|dashscope\\|zai\\|minimax\\|jimeng\\|seedream\\|replicate\\|codex-cli\\|agnes` | Force provider (default: auto-detect; `codex-cli` is never auto-selected — must be pinned via CLI or EXTEND.md) |\n| `--model \u003Cid>`, `-m` | Model ID — see provider references for defaults and allowed values |\n| `--ar \u003Cratio>` | Aspect ratio (`16:9`, `1:1`, `4:3`, …) |\n| `--size \u003CWxH>` | Explicit size (e.g., `1024x1024`; for `gpt-image-2.5-*` and `gpt-image-2`, width\u002Fheight must be multiples of 16, max edge 3840px, ratio no wider than 3:1) |\n| `--quality normal\\|2k` | Quality preset (default: `2k`) |\n| `--imageSize 1K\\|2K\\|4K` | Image size for Google\u002FOpenRouter (default: from quality) |\n| `--imageApiDialect openai-native\\|ratio-metadata` | OpenAI-compatible endpoint dialect — use `ratio-metadata` for gateways that expect aspect-ratio `size` plus `metadata.resolution` |\n| `--ref \u003Cfiles...>` | Reference images. Supported by Google multimodal, OpenAI GPT Image edits, Azure OpenAI edits (PNG\u002FJPG only), OpenRouter multimodal models, Replicate supported families, MiniMax subject-reference, Seedream 5.0\u002F4.5\u002F4.0, DashScope `wan2.7-image-pro`\u002F`wan2.7-image`. Not supported by Jimeng, Seedream 3.0, SeedEdit 3.0, or any DashScope model outside the `wan2.7-image*` family |\n| `--n \u003Ccount>` | Number of images. Replicate requires `--n 1` (single-output save semantics) |\n| `--json` | JSON output |\n\n## Environment Variables\n\n| Variable | Description |\n|----------|-------------|\n| `OPENAI_API_KEY` | OpenAI API key |\n| `AZURE_OPENAI_API_KEY` | Azure OpenAI API key |\n| `OPENROUTER_API_KEY` | OpenRouter API key |\n| `GOOGLE_API_KEY` | Google API key |\n| `DASHSCOPE_API_KEY` | DashScope API key |\n| `ZAI_API_KEY` (alias `BIGMODEL_API_KEY`) | Z.AI API key |\n| `MINIMAX_API_KEY` | MiniMax API key |\n| `REPLICATE_API_TOKEN` | Replicate API token |\n| `JIMENG_ACCESS_KEY_ID`, `JIMENG_SECRET_ACCESS_KEY` | Jimeng (即梦) Volcengine credentials |\n| `ARK_API_KEY` | Seedream (豆包) Volcengine ARK API key |\n| `\u003CPROVIDER>_IMAGE_MODEL` | Per-provider model override (`OPENAI_IMAGE_MODEL`, `GOOGLE_IMAGE_MODEL`, `DASHSCOPE_IMAGE_MODEL`, `ZAI_IMAGE_MODEL`\u002F`BIGMODEL_IMAGE_MODEL`, `MINIMAX_IMAGE_MODEL`, `OPENROUTER_IMAGE_MODEL`, `REPLICATE_IMAGE_MODEL`, `JIMENG_IMAGE_MODEL`, `SEEDREAM_IMAGE_MODEL`, `AGNES_IMAGE_MODEL`) |\n| `AZURE_OPENAI_DEPLOYMENT` (alias `AZURE_OPENAI_IMAGE_MODEL`) | Azure default deployment |\n| `\u003CPROVIDER>_BASE_URL` | Per-provider endpoint override |\n| `AZURE_API_VERSION` | Azure image API version (default `2025-04-01-preview`) |\n| `JIMENG_REGION` | Jimeng region (default `cn-north-1`) |\n| `OPENAI_IMAGE_API_DIALECT` | `openai-native` \\| `ratio-metadata` |\n| `OPENROUTER_HTTP_REFERER`, `OPENROUTER_TITLE` | Optional OpenRouter attribution |\n| `BAOYU_IMAGE_GEN_MAX_WORKERS` | Override batch worker cap |\n| `BAOYU_IMAGE_GEN_\u003CPROVIDER>_CONCURRENCY` | Per-provider concurrency (e.g., `BAOYU_IMAGE_GEN_REPLICATE_CONCURRENCY`; for codex-cli use `BAOYU_IMAGE_GEN_CODEX_CLI_CONCURRENCY`) |\n| `BAOYU_IMAGE_GEN_\u003CPROVIDER>_START_INTERVAL_MS` | Per-provider start-gap |\n| `BAOYU_CODEX_IMAGEGEN_BIN` | Override the codex-imagegen wrapper path for the `codex-cli` provider (default: bundled `scripts\u002Fcodex-imagegen\u002Fmain.ts`; accepts `.ts` or legacy `.sh`\u002Fbinary) |\n| `BAOYU_CODEX_IMAGEGEN_CACHE_DIR` | Enable idempotency cache for the `codex-cli` provider (off by default) |\n| `BAOYU_CODEX_IMAGEGEN_TIMEOUT_MS` | Per-attempt `codex exec` timeout for the `codex-cli` provider (default: 300000 ms) |\n| `BAOYU_CODEX_IMAGEGEN_RETRIES` | Wrapper-side retry attempts on retryable errors for the `codex-cli` provider (default: 2) |\n| `BAOYU_CODEX_IMAGEGEN_LOG_FILE` | Append JSONL diagnostic log for the `codex-cli` provider |\n\n**Load priority**: CLI args > EXTEND.md > env vars > `\u003Ccwd>\u002F.baoyu-skills\u002F.env` > `~\u002F.baoyu-skills\u002F.env`\n\n### Codex\u002FChatGPT OAuth is not an OpenAI API key\n\n`--provider openai --model gpt-image-2.5-flare` uses the standard OpenAI Images API (`\u002Fv1\u002Fimages\u002Fgenerations` or `\u002Fv1\u002Fimages\u002Fedits`) and requires `OPENAI_API_KEY`. A Codex or ChatGPT desktop login is a different entitlement and is not a drop-in replacement for `OPENAI_API_KEY`; do not paste a Codex OAuth token into `OPENAI_API_KEY` or only set `OPENAI_BASE_URL` to a Codex backend.\n\nIf the user wants to use their Codex subscription \u002F GPT Image 2 entitlement without an OpenAI API key, route through a Codex-native backend instead of this skill's `openai` provider:\n\n- In Codex runtime: use the native `imagegen` skill\u002Ftool.\n- In non-Codex runtimes with `codex` CLI installed and logged in: use `baoyu-image-gen --provider codex-cli` (preferred — it gives you the same retry \u002F cache \u002F batch flow as every other provider). The provider spawns the bundled `scripts\u002Fcodex-imagegen\u002Fmain.ts`; the same code lives upstream at `packages\u002Fbaoyu-codex-imagegen\u002Fsrc\u002Fmain.ts` for standalone callers.\n- In Hermes runtimes with a native `image_generate` tool: use that tool as a fallback, and state whether reference images were passed directly or reconstructed from extracted traits.\n\nDo not modify the existing `openai` provider to silently consume Codex OAuth. The first-class Codex-CLI path is the dedicated `codex-cli` provider, which has its own auth (Codex login), route (`codex exec`), request shape, and tests. See `references\u002Fcodex-oauth-vs-openai-api-key.md`.\n\n## Model Resolution\n\nPriority (highest → lowest) applies to every provider:\n\n1. CLI flag `--model \u003Cid>`\n2. EXTEND.md `default_model.[provider]`\n3. Env var `\u003CPROVIDER>_IMAGE_MODEL`\n4. Built-in default\n\nFor OpenAI, the built-in default is `gpt-image-2.5-flare` (fast, lowest latency). `gpt-image-2.5-sunburst` is the most capable variant for complex scenes and precise edits; `gpt-image-2`, `gpt-image-1.5`, `gpt-image-1`, and dated GPT Image snapshots (e.g. `gpt-image-2.5-flare-2026-09-08`, `gpt-image-2-2026-04-21`) remain selectable with `--model` or `OPENAI_IMAGE_MODEL`.\n\nFor Google, the built-in default is `gemini-3-pro-image`. `gemini-3.1-flash-image` is the faster low-cost option, and `gemini-3.1-flash-lite-image` is the cheapest — it only produces 1K output, so `--quality 2k` \u002F `--imageSize 2K|4K` is clamped to 1K with a warning.\n\nFor DashScope, the built-in default is `qwen-image-2.0-pro`; `qwen-image-3.0-pro` is the newest flagship and uses the same sizing rules.\n\nFor Azure, `--model` \u002F `default_model.azure` is the Azure deployment name. `AZURE_OPENAI_DEPLOYMENT` is the preferred env var; `AZURE_OPENAI_IMAGE_MODEL` is kept as a backward-compatible alias. If your Azure deployment is named after the underlying model, use `gpt-image-2.5-flare`; otherwise use the exact custom deployment name.\n\nEXTEND.md overrides env vars: if EXTEND.md sets `default_model.google: \"gemini-3-pro-image\"` and the env var sets `GOOGLE_IMAGE_MODEL=gemini-3.1-flash-image`, EXTEND.md wins.\n\n**Display model info before each generation**:\n\n- `Using [provider] \u002F [model]`\n- `Switch model: --model \u003Cid> | EXTEND.md default_model.[provider] | env \u003CPROVIDER>_IMAGE_MODEL`\n\n## OpenAI-Compatible Gateway Dialects\n\n`provider=openai` means the auth and routing entrypoint is OpenAI-compatible. It does **not** guarantee the upstream image API uses OpenAI native semantics. When a gateway expects a different wire format, set `default_image_api_dialect` in EXTEND.md, `OPENAI_IMAGE_API_DIALECT`, or `--imageApiDialect`:\n\n- `openai-native`: pixel `size` (`1536x1024`) and native OpenAI quality fields\n- `ratio-metadata`: aspect-ratio `size` (`16:9`) plus `metadata.resolution` (`1K|2K|4K`) and `metadata.orientation`\n\nUse `openai-native` for the OpenAI native API or strict clones; try `ratio-metadata` for compatibility gateways in front of Gemini or similar models. Current limitation: `ratio-metadata` applies only to text-to-image; reference-image edits still need `openai-native` or a provider with first-class edit support.\n\n## Provider-Specific Guides\n\nEach provider has its own quirks (model families, size rules, ref support, limits). Read these when the user picks that provider or asks for non-default behavior:\n\n| Provider | Reference |\n|----------|-----------|\n| DashScope (Qwen-Image families, custom sizes) | `references\u002Fproviders\u002Fdashscope.md` |\n| Z.AI (GLM-Image, cogview-4) | `references\u002Fproviders\u002Fzai.md` |\n| MiniMax (image-01, subject-reference) | `references\u002Fproviders\u002Fminimax.md` |\n| OpenRouter (multimodal models, `\u002Fchat\u002Fcompletions` flow) | `references\u002Fproviders\u002Fopenrouter.md` |\n| Replicate (nano-banana, Seedream, Wan) | `references\u002Fproviders\u002Freplicate.md` |\n| Codex CLI (wraps bundled `scripts\u002Fcodex-imagegen\u002F`; Codex login, no `OPENAI_API_KEY`) | `references\u002Fproviders\u002Fcodex-cli.md` |\n| Agnes (agnes-image-2.1-flash, reference-image support) | `references\u002Fproviders\u002Fagnes.md` |\n\n## Provider Selection\n\n1. `--ref` provided + no `--provider` → auto-select Google → OpenAI → Azure → OpenRouter → Replicate → Seedream → MiniMax → Agnes (MiniMax's subject reference is more specialized toward character\u002Fportrait consistency)\n2. `--provider` specified → use it (if `--ref`, must be google\u002Fopenai\u002Fazure\u002Fopenrouter\u002Freplicate\u002Fseedream\u002Fminimax\u002Fcodex-cli\u002Fagnes)\n3. Only one API key present → use that provider\n4. Multiple keys → default priority: Google → OpenAI → Azure → OpenRouter → DashScope → Z.AI → MiniMax → Replicate → Jimeng → Seedream → Agnes\n5. `codex-cli` is **never auto-selected** — set `default_provider: codex-cli` in EXTEND.md or pass `--provider codex-cli`. It spawns `codex exec` via the bundled `scripts\u002Fcodex-imagegen\u002Fmain.ts` TS entrypoint (run with `bun`) and uses the user's Codex subscription (no `OPENAI_API_KEY`). Requires `codex` on `PATH` with an active `codex login`.\n\n## Quality Presets\n\n| Preset | Google imageSize | OpenAI size | OpenRouter size | Replicate resolution | Use case |\n|--------|------------------|-------------|-----------------|----------------------|----------|\n| `normal` | 1K | 1024px target | 1K | 1K | Quick previews |\n| `2k` (default) | 2K | 2048px target | 2K | 2K | Covers, illustrations, infographics |\n\nGoogle\u002FOpenRouter `imageSize` can be overridden with `--imageSize 1K|2K|4K`.\n\nFor OpenAI native `gpt-image-2.5-*` and `gpt-image-2`, `normal` maps to `quality=medium` and a low-latency valid size near the requested aspect ratio; `2k` maps to `quality=high` and 2048px-class sizes such as `2048x2048`, `2048x1152`, or `1152x2048`. Use explicit `--size` for valid custom or 4K outputs, e.g. `3840x2160`.\n\n## Aspect Ratios\n\nSupported: `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `2.35:1`.\n\n- Google multimodal: `imageConfig.aspectRatio`\n- OpenAI: `gpt-image-2.5-*` and `gpt-image-2` use the closest valid custom size for the requested ratio; older GPT Image and DALL·E models use their closest supported fixed size\n- OpenRouter: `imageGenerationOptions.aspect_ratio`; if only `--size \u003CWxH>` is given, the ratio is inferred\n- Replicate: behavior is model-specific — `google\u002Fnano-banana*` uses `aspect_ratio`, `bytedance\u002Fseedream-*` uses documented Replicate ratios, Wan 2.7 maps `--ar` to a concrete `size`\n- MiniMax: official `aspect_ratio` values; if `--size \u003CWxH>` is given without `--ar`, sends `width`\u002F`height` for `image-01`\n\n## Generation Mode\n\n**Default**: sequential. **Batch parallel**: enabled automatically when `--batchfile` contains 2+ pending tasks.\n\n| Situation | Prefer | Why |\n|-----------|--------|-----|\n| One image, or 1-2 simple images | Sequential | Lower coordination overhead, easier debugging |\n| Multiple images with saved prompt files | Batch (`--batchfile`) | Reuses finalized prompts, applies shared throttling\u002Fretries, predictable throughput |\n| Each image still needs its own reasoning \u002F prompt writing \u002F style exploration | Subagents | Work is still exploratory, each needs independent analysis |\n| Input is `outline.md` + `prompts\u002F` (e.g. from `baoyu-article-illustrator`) | Batch — use `{baseDir}\u002Fscripts\u002Fbuild-batch.ts` to assemble the payload | The outline + prompt files already contain everything needed |\n\nRule of thumb: once prompt files are saved and the task is \"generate all of these\", prefer batch over subagents. Use subagents only when generation is coupled with per-image thinking or divergent creative exploration.\n\n**Parallel behavior**:\n\n- Default worker count is automatic, capped by config, built-in default 10\n- Provider-specific throttling applies only in batch mode; defaults are tuned for throughput while avoiding RPM bursts\n- Override with `--jobs \u003Ccount>`\n- Each image retries up to 3 attempts\n- Final output includes success count, failure count, and per-image failure reasons\n\n## Error Handling\n\n- Missing API key → error with setup instructions\n- Generation failure → auto-retry up to 3 attempts per image\n- Invalid aspect ratio → warning, proceed with default\n- Reference images with unsupported provider\u002Fmodel → error with fix hint\n\n### Codex image2 fallback\n\nIf `--provider openai --model gpt-image-2.5-flare` fails because `OPENAI_API_KEY` is missing but the current runtime has a native image-generation backend or the repo-level `codex-imagegen` wrapper is available, use that path rather than leaving the user waiting. Be explicit about whether the fallback is true reference-image generation or only a text-prompt reconstruction from extracted visual traits. See `references\u002Fcodex-image2-fallback.md`.\n\n## References\n\n| File | Content |\n|------|---------|\n| `references\u002Fusage-examples.md` | Extended CLI examples across providers and batch mode |\n| `references\u002Fcodex-oauth-vs-openai-api-key.md` | Why Codex\u002FChatGPT OAuth image2 entitlement is not usable through baoyu-image-gen's standard OpenAI API-key provider |\n| `references\u002Fcodex-image2-fallback.md` | Practical fallback behavior when OpenAI API credentials are absent but Codex\u002Fnative image generation is available |\n| `references\u002Fproviders\u002Fdashscope.md` | DashScope families, sizes, limits |\n| `references\u002Fproviders\u002Fzai.md` | Z.AI GLM-image \u002F cogview-4 |\n| `references\u002Fproviders\u002Fminimax.md` | MiniMax image-01 + subject reference |\n| `references\u002Fproviders\u002Fopenrouter.md` | OpenRouter multimodal flow |\n| `references\u002Fproviders\u002Freplicate.md` | Replicate supported families + guardrails |\n| `references\u002Fproviders\u002Fagnes.md` | Agnes (agnes-image-2.1-flash) sizing, refs, and limits |\n| `references\u002Fconfig\u002Fpreferences-schema.md` | EXTEND.md schema |\n| `references\u002Fconfig\u002Ffirst-time-setup.md` | First-time setup flow |\n\n## Extension Support\n\nCustom configurations via EXTEND.md. See Step 0 for paths and schema.\n",{"name":5,"version":24,"metadata":25,"description":7},"2.2.0",{"openclaw":26},{"homepage":27,"requires":28},"https:\u002F\u002Fgithub.com\u002FJimLiu\u002Fbaoyu-skills#baoyu-image-gen",{"anyBins":29},[30,31],"bun","npx","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","03-逆向工程\u002Fbaoyu-image-gen",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":41,"prompt":50,"zipAvailable":51},[42,44,47],{"tool":31,"command":43},"npx skills add lza6\u002FArmor-piercing-system-prompts --skill baoyu-image-gen",{"tool":45,"command":46},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill baoyu-image-gen",{"tool":48,"command":49},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill baoyu-image-gen","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002FSKILL.md",true,[53,59,63,67,71,75,79,83,87,91,95,99],{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"references\u002Fcodex-image2-fallback.md","REFERENCE","参考文档",1993,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fcodex-image2-fallback.md",{"path":60,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":61,"sourceHtmlUrl":62},"references\u002Fcodex-oauth-vs-openai-api-key.md",2137,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fcodex-oauth-vs-openai-api-key.md",{"path":64,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fconfig\u002Ffirst-time-setup.md",14427,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fconfig\u002Ffirst-time-setup.md",{"path":68,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":69,"sourceHtmlUrl":70},"references\u002Fconfig\u002Fpreferences-schema.md",5001,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fconfig\u002Fpreferences-schema.md",{"path":72,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fproviders\u002Fagnes.md",2301,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fproviders\u002Fagnes.md",{"path":76,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fproviders\u002Fcodex-cli.md",6011,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fproviders\u002Fcodex-cli.md",{"path":80,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fproviders\u002Fdashscope.md",4950,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fproviders\u002Fdashscope.md",{"path":84,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fproviders\u002Fminimax.md",1228,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fproviders\u002Fminimax.md",{"path":88,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fproviders\u002Fopenrouter.md",760,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fproviders\u002Fopenrouter.md",{"path":92,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Fproviders\u002Freplicate.md",1814,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fproviders\u002Freplicate.md",{"path":96,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":97,"sourceHtmlUrl":98},"references\u002Fproviders\u002Fzai.md",1099,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fproviders\u002Fzai.md",{"path":100,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":101,"sourceHtmlUrl":102},"references\u002Fusage-examples.md",6128,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F03-逆向工程\u002Fbaoyu-image-gen\u002Freferences\u002Fusage-examples.md",[104,112,117,124,131,138],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":111},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":113,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":111},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":111},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":111},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":111},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":111},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]