home / skills / steipete / agent-scripts / openai-image-gen

openai-image-gen skill

/skills/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-gen

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.0 KB
---
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)

Overview

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.

How this skill works

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.

When to use it

  • Generate a batch of concept images for brainstorming or moodboards.
  • Create variations from a single prompt to explore visual options.
  • Quickly produce PNG outputs and an HTML gallery for client review.
  • Automate image generation in a pipeline or local experiment.

Best practices

  • Set OPENAI_API_KEY in your environment before running the script.
  • Use --count to control how many images you want and --model to pick the image model.
  • Pin output directories with --out-dir to keep results organized and reproducible.
  • Start with medium sizes then increase size only for final renders to save API usage.
  • Keep a local copy of prompts.json to track prompt ↔ image provenance.

Example use cases

  • Generate 16 concept images for a design sprint using --count 16.
  • Explore variations from a single idea: use --prompt and --count 4.
  • Produce high-quality renders for presentation: use --quality high and larger --size.
  • Create a quick portfolio preview by opening the generated index.html gallery.

FAQ

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.