Openai Image Gen
Scanned@saschaSpoonbill
npx machina-cli add skill @saschaSpoonbill/openai-image-gen-fixed --openclawOpenAI 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/...):
python3 ~/Projects/agent-scripts/skills/openai-image-gen/scripts/gen.py
open ~/Projects/tmp/openai-image-gen-*/index.html
Useful flags:
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
*.pngimagesprompts.json(prompt ↔ file mapping)index.html(thumbnail gallery)
Overview
OpenAI Image Gen automates batch image creation by sampling structured random prompts and rendering them with the OpenAI Images API. It outputs PNGs, a prompts.json mapping, and an index.html thumbnail gallery for offline review, all controlled by your OPENAI_API_KEY. This setup is ideal for rapid concept exploration and asset generation.
How This Skill Works
The gen.py script builds a set of prompts using a random-but-structured sampler and sends them to the OpenAI Images API. Generated assets, including PNGs, prompts.json, and an index.html gallery, are written to a tmp directory (or ~/Projects/tmp if present). You can customize output with flags like --count, --model, --size, and --out-dir.
When to Use It
- Need multiple visuals for concept exploration or mood boards.
- Want to test diverse prompt styles by sampling variations.
- Prepare assets for a portfolio, website, or social thumbnails.
- Require an offline review gallery via index.html before sharing.
- Tune batch size, image size, and model to balance quality and cost.
Quick Start
- Step 1: Set OPENAI_API_KEY in your environment.
- Step 2: Run the generator: python3 ~/Projects/agent-scripts/skills/openai-image-gen/scripts/gen.py
- Step 3: Open the gallery: open ~/Projects/tmp/openai-image-gen-*/index.html
Best Practices
- Set OPENAI_API_KEY in your environment before running.
- Start with a small --count to test prompts, then scale up.
- Use --size to control resolution and cost; larger images take longer.
- Use --prompt to override the sampler for targeted prompts and document results in prompts.json.
- Inspect prompts.json to map each prompt to its corresponding PNG and gallery entry; keep outputs organized with --out-dir.
Example Use Cases
- 16-image batch of sci‑fi character concepts using the random sampler and gpt-image-1.5.
- Ultra-detailed prompt like 'ultra-detailed studio photo of a lobster astronaut' for a playful product shot.
- Product render mocks for a new gadget with 1536x1024 size.
- Website hero thumbnails library for a portfolio site.
- Offline client review: open index.html in tmp/openai-image-gen-*/index.html to share assets.