$npx -y skills add openai/codex --skill imagegenGenerate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variant
| 1 | # Image Generation Skill |
| 2 | |
| 3 | Generates or edits images for the current project (for example website assets, game assets, UI mockups, product mockups, wireframes, logo design, photorealistic images, or infographics). |
| 4 | |
| 5 | ## Top-level modes and rules |
| 6 | |
| 7 | This skill has exactly two top-level modes: |
| 8 | |
| 9 | - **Default built-in tool mode (preferred):** built-in `image_gen` tool for normal image generation, editing, and simple transparent-image requests. Does not require `OPENAI_API_KEY`. |
| 10 | - **Fallback CLI mode:** `scripts/image_gen.py` CLI. Use when the user explicitly asks for the CLI/API/model path, or after the user explicitly confirms a true model-native transparency fallback with `gpt-image-1.5`. Requires `OPENAI_API_KEY`. |
| 11 | |
| 12 | Within CLI fallback, the CLI exposes three subcommands: |
| 13 | |
| 14 | - `generate` |
| 15 | - `edit` |
| 16 | - `generate-batch` |
| 17 | |
| 18 | Rules: |
| 19 | - Use the built-in `image_gen` tool by default for normal image generation and editing requests. |
| 20 | - Do not switch to CLI fallback for ordinary quality, size, or file-path control. |
| 21 | - If the user explicitly asks for a transparent image/background, stay on built-in `image_gen` first: prompt for a flat removable chroma-key background, then remove it locally with the installed helper at `$CODEX_HOME/skills/.system/imagegen/scripts/remove_chroma_key.py`. |
| 22 | - Never silently switch from built-in `image_gen` or CLI `gpt-image-2` to CLI `gpt-image-1.5`. Treat this as a model/path downgrade and ask the user before doing it, unless the user has already explicitly requested `gpt-image-1.5`, `scripts/image_gen.py`, or CLI fallback. |
| 23 | - If a transparent request appears too complex for clean chroma-key removal, asks for true/native transparency, or local removal fails validation, explain that true transparency requires CLI `gpt-image-1.5 --background transparent --output-format png` because `gpt-image-2` does not support `background=transparent`, then ask whether to proceed. Run the CLI fallback only after the user confirms. |
| 24 | - The word `batch` by itself does not mean CLI fallback. If the user asks for many assets or says to batch-generate assets without explicitly asking for CLI/API/model controls, stay on the built-in path and issue one built-in call per requested asset or variant. |
| 25 | - If the built-in tool fails or is unavailable, tell the user the CLI fallback exists and that it requires `OPENAI_API_KEY`. Proceed only if the user explicitly asks for that fallback. |
| 26 | - If the user explicitly asks for CLI mode, use the bundled `scripts/image_gen.py` workflow. Do not create one-off SDK runners. |
| 27 | - Never modify `scripts/image_gen.py`. If something is missing, ask the user before doing anything else. |
| 28 | |
| 29 | Built-in save-path policy: |
| 30 | - In built-in tool mode, Codex saves generated images under `$CODEX_HOME/*` by default. |
| 31 | - Do not describe or rely on OS temp as the default built-in destination. |
| 32 | - Do not describe or rely on a destination-path argument (if any) on the built-in `image_gen` tool. If a specific location is needed, generate first and then move or copy the selected output from `$CODEX_HOME/generated_images/...`. |
| 33 | - Save-path precedence in built-in mode: |
| 34 | 1. If the user names a destination, move or copy the selected output there. |
| 35 | 2. If the image is meant for the current project, move or copy the final selected image into the workspace before finishing. |
| 36 | 3. If the image is only for preview or brainstorming, render it inline; the underlying file can remain at the default `$CODEX_HOME/*` path. |
| 37 | - Never leave a project-referenced asset only at the default `$CODEX_HOME/*` path. |
| 38 | - Do not overwrite an existing asset unless the user explicitly asked for replacement; otherwise create a sibling versioned filename such as `hero-v2.png` or `item-icon-edited.png`. |
| 39 | |
| 40 | Shared prompt guidance for both modes lives in `references/prompting.md` and `references/sample-prompts.md`. |
| 41 | |
| 42 | Fallback-only docs/resources for CLI mode: |
| 43 | - `references/cli.md` |
| 44 | - `references/image-api.md` |
| 45 | - `references/codex-network.md` |
| 46 | - `scripts/image_gen.py` |
| 47 | |
| 48 | Local post-processing helper: |
| 49 | - `$CODEX_HOME/skills/.system/imagegen/scripts/remove_chroma_key.py`: removes a flat chroma-key background from a generated image and writes a PNG/WebP with alpha. Prefer auto-key sampling, soft matte, and despill for antialiased edges. |
| 50 | |
| 51 | ## When to use |
| 52 | - Generate a new image (concept art, product shot, cover, website hero) |
| 53 | - Generate a new image using one or more reference images for style, |