All skills
openai avatar

/imagegen

@0ebe69a official
by openaiopenai/skills28k stars
1,891

Generate 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 variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handled by editing existing SVG/vector/code-native assets, extending an established icon or logo system, or building the visual directly in HTML/CSS/canvas.

Use this Skill: https://skilld.dev/gh/openai/skills/imagegen

This session only. Nothing lands on disk.

referencescli.md

≈1.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

CLI reference (scripts/image_gen.py)

This file is for the fallback CLI mode only. Read it only after the user explicitly asks to use scripts/image_gen.py instead of the built-in image_gen tool.

generate-batch is a CLI subcommand in this fallback path. It is not a top-level mode of the skill.

What this CLI does

  • generate: generate a new image from a prompt
  • edit: edit one or more existing images
  • generate-batch: run many generation jobs from a JSONL file

Real API calls require network access + OPENAI_API_KEY. --dry-run does not.

Quick start (works from any repo)

Set a stable path to the skill CLI (default CODEX_HOME is ~/.codex):

export CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
export IMAGE_GEN="$CODEX_HOME/skills/.system/imagegen/scripts/image_gen.py"

Install dependencies into that environment with its package manager. In uv-managed environments, uv pip install ... remains the preferred path.

Quick start

Dry-run (no API call; no network required; does not require the openai package):

python "$IMAGE_GEN" generate \
  --prompt "Test" \
  --out output/imagegen/test.png \
  --dry-run

Notes:

  • One-off dry-runs print the API payload and the computed output path(s).
  • Repo-local finals should live under output/imagegen/.

Generate (requires OPENAI_API_KEY + network):

python "$IMAGE_GEN" generate \
  --prompt "A cozy alpine cabin at dawn" \
  --size 1024x1024 \
  --out output/imagegen/alpine-cabin.png

Edit:

python "$IMAGE_GEN" edit \
  --image input.png \
  --prompt "Replace only the background with a warm sunset" \
  --out output/imagegen/sunset-edit.png

Guardrails

  • Use the bundled CLI directly (python "$IMAGE_GEN" ...) after activating the correct environment.
  • Do not create one-off runners (for example gen_images.py) unless the user explicitly asks for a custom wrapper.
  • Never modify scripts/image_gen.py. If something is missing, ask the user before doing anything else.

Defaults

  • Model: gpt-image-1.5
  • Supported model family for this CLI: GPT Image models (gpt-image-*)
  • Size: 1024x1024
  • Quality: auto
  • Output format: png
  • Default one-off output path: output/imagegen/output.png
  • Background: unspecified unless --background is set

Quality, input fidelity, and masks (CLI fallback only)

These are explicit CLI controls. They are not built-in image_gen tool arguments.

  • --quality works for generate, edit, and generate-batch: low|medium|high|auto
  • --input-fidelity is edit-only and validated as low|high
  • --mask is edit-only

Example:

python "$IMAGE_GEN" edit \
  --image input.png \
  --prompt "Change only the background" \
  --quality high \
  --input-fidelity high \
  --out output/imagegen/background-edit.png

Mask notes:

  • For multi-image edits, pass repeated --image flags. Their order is meaningful, so describe each image by index and role in the prompt.
  • The CLI accepts a single --mask.
  • Use a PNG mask when possible; the script treats mask handling as best-effort and does not perform full preflight validation beyond file checks/warnings.
  • In the edit prompt, repeat invariants (change only the background; keep the subject unchanged) to reduce drift.

Output handling

  • Use tmp/imagegen/ for temporary JSONL inputs or scratch files.
  • Use output/imagegen/ for final outputs.
  • Reruns fail if a target file already exists unless you pass --force.
  • --out-dir changes one-off naming to image_1.<ext>, image_2.<ext>, and so on.
  • Downscaled copies use the default suffix -web unless you override it.

Common recipes

Generate with augmentation fields:

python "$IMAGE_GEN" generate \
  --prompt "A minimal hero image of a ceramic coffee mug" \
  --use-case "product-mockup" \
  --style "clean product photography" \
  --composition "wide product shot with usable negative space for page copy" \
  --constraints "no logos, no text" \
  --out output/imagegen/mug-hero.png

Generate + also write a downscaled copy for fast web loading:

python "$IMAGE_GEN" generate \
  --prompt "A cozy alpine cabin at dawn" \
  --size 1024x1024 \
  --downscale-max-dim 1024 \
  --out output/imagegen/alpine-cabin.png

Generate multiple prompts concurrently (async batch):

mkdir -p tmp/imagegen output/imagegen/batch
cat > tmp/imagegen/prompts.jsonl << 'EOF'
{"prompt":"Cavernous hangar interior with a compact shuttle parked near the center","use_case":"stylized-concept","composition":"wide-angle, low-angle","lighting":"volumetric light rays through drifting fog","constraints":"no logos or trademarks; no watermark","size":"1536x1024"}
{"prompt":"Gray wolf in profile in a snowy forest","use_case":"photorealistic-natural","composition":"eye-level","constraints":"no logos or trademarks; no watermark","size":"1024x1024"}
EOF

python "$IMAGE_GEN" generate-batch \
  --input tmp/imagegen/prompts.jsonl \
  --out-dir output/imagegen/batch \
  --concurrency 5

rm -f tmp/imagegen/prompts.jsonl

Notes:

  • generate-batch requires --out-dir.
  • generate-batch requires --out-dir.
  • Use --concurrency to control parallelism (default 5).
  • Per-job overrides are supported in JSONL (for example size, quality, background, output_format, output_compression, moderation, n, model, out, and prompt-augmentation fields).
  • --n generates multiple variants for a single prompt; generate-batch is for many different prompts.
  • In batch mode, per-job out is treated as a filename under --out-dir.

CLI notes

  • Supported sizes: 1024x1024, 1536x1024, 1024x1536, or auto.
  • Transparent backgrounds require output_format to be png or webp.
  • --prompt-file, --output-compression, --moderation, --max-attempts, --fail-fast, --force, and --no-augment are supported.
  • This CLI is intended for GPT Image models. Do not assume older non-GPT image-model behavior applies here.

See also

  • API parameter quick reference for fallback CLI mode: references/image-api.md
  • Prompt examples shared across both top-level modes: references/sample-prompts.md
  • Network/sandbox notes for fallback CLI mode: references/codex-network.md

Source: SKILL.md on GitHub

1 warning16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides capabilities for image generation and editing using a built-in tool or an explicit CLI fallback. A review of the files indicates that standard practices are followed, including secure handling of API keys via environment variables and path sanitization to avoid path traversal concerns.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    6/9 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 0ebe69a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Activeupdated 6 months ago
  • image-generation
  • ai-image
  • openai
  • asset-creation
  • photo-mockup
  • illustration
  • editing
  • texture
  • sprite

README badge

README badge for openai/skills/imagegen

Generates or edits bitmap images for projects using a built-in tool by default, with a fallback CLI mode available on request. Targets product mockups, website assets, UI mockups, game sprites, concept art, and image editing tasks like background removal or object replacement. Does not handle vector graphics, icon systems, or code-native visual assets.

Generated from the current SKILL.md.

Does this skill work with local image files?
Yes. For editing local files with the built-in tool, first load the image with the `view_image` tool so it appears in conversation context, then proceed with the edit. For direct file-path control and advanced parameters, use the explicit CLI fallback mode (which requires OPENAI_API_KEY) only when explicitly requested.
What's the difference between the built-in tool and the CLI fallback?
The built-in `image_gen` tool is the default for normal generation and editing; it does not require an API key. The CLI fallback (`scripts/image_gen.py`) offers subcommands like `generate-batch` and explicit parameters like masks and input fidelity, but only use it if you explicitly ask for the CLI path and set OPENAI_API_KEY.
Where are generated images saved by default?
Generated images are saved under `$CODEX_HOME/generated_images/` by default. For project-bound assets, they must be moved or copied into the workspace before finishing; do not leave project-referenced assets only at the default path.
Can I generate multiple image variants in one request?
Yes. In built-in mode, issue one `image_gen` call per variant. In explicit CLI mode, use the `generate-batch` subcommand if you need to generate many prompts at once.
Should I use this skill for SVG icons or logos that match existing repo code?
No. For icons, logos, or UI graphics that should match existing SVG/vector/code-native assets in the repo, edit those directly instead. Use this skill when you need raster output like photos, illustrations, sprites, mockups, or transparent-background cutouts.

Generated from the current SKILL.md. These answers refresh after source changes.