home / skills / steipete / agent-scripts / openai-image-gen
This skill batch-generates images via OpenAI Images API using a random prompt sampler and provides an index.html gallery.
npx playbooks add skill steipete/agent-scripts --skill openai-image-genReview the files below or copy the command above to add this skill to your agents.
---
name: openai-image-gen
description: Batch-generate images via OpenAI Images API. Random prompt sampler + `index.html` gallery.
---
# OpenAI Image Gen
Generate a handful of “random but structured” prompts and render them via OpenAI Images API.
## Setup
- Needs env: `OPENAI_API_KEY`
## Run
From any directory (outputs to `~/Projects/tmp/...` when present; else `./tmp/...`):
```bash
python3 ~/Projects/agent-scripts/skills/openai-image-gen/scripts/gen.py
open ~/Projects/tmp/openai-image-gen-*/index.html
```
Useful flags:
```bash
python3 ~/Projects/agent-scripts/skills/openai-image-gen/scripts/gen.py --count 16 --model gpt-image-1.5
python3 ~/Projects/agent-scripts/skills/openai-image-gen/scripts/gen.py --prompt "ultra-detailed studio photo of a lobster astronaut" --count 4
python3 ~/Projects/agent-scripts/skills/openai-image-gen/scripts/gen.py --size 1536x1024 --quality high --out-dir ./out/images
```
## Output
- `*.png` images
- `prompts.json` (prompt ↔ file mapping)
- `index.html` (thumbnail gallery)
This skill batch-generates images using the OpenAI Images API and produces a simple thumbnail gallery. It samples a set of random-but-structured prompts or accepts a custom prompt, renders PNG outputs, and writes a mapping file and an index.html for quick review. It’s implemented in TypeScript tooling and intended for quick experimentation and visual prototyping.
The script samples or accepts prompts, calls the OpenAI Images API for each prompt, and saves generated PNG files. It writes prompts.json to map prompts to filenames and creates an index.html gallery with thumbnails for rapid inspection. Configuration is via CLI flags and the OPENAI_API_KEY environment variable.
What environment variables are required?
Set OPENAI_API_KEY with a valid OpenAI API key before running the tool.
Where are outputs saved?
By default the tool writes to ./tmp/... or ~/Projects/tmp/... when that path exists; you can override with --out-dir.