| name | openai-image-generator |
| description | Generate images using OpenAI gpt-image-2 with customizable options |
openai-image-generator
Instructions
Use this skill to generate images using OpenAI's gpt-image-2 model. The skill supports:
- Text-to-image generation from prompts (
images.generate)
- Image editing / composition with one or more reference images (
images.edit)
- Size presets (square, landscape, portrait, 2K) or a raw
WxH string
- Quality levels (low / medium / high / auto)
- Custom output paths
The API key should be set via the OPENAI_API_KEY environment variable.
Parameters
--prompt (required): The text prompt describing the image to generate
--output (required): Output file path for the generated image
--reference: Optional reference image path. Can be specified multiple times. When provided, the edits endpoint is used.
--size: Output size. Accepts a preset (square, landscape, portrait, 2K) or a raw WxH string (e.g. 1920x1080). Default: square (1024x1024).
--quality: low, medium, high, or auto (default: auto)
Size constraints for gpt-image-2: max edge 3840px, both edges multiples of 16, aspect ratio ≤ 3:1, total pixels between 655,360 and 8,294,400.
Examples
Basic text-to-image generation
./scripts/generate.py --prompt "A serene mountain landscape at sunset" --output images/landscape.png
With reference image(s) for editing / composition
./scripts/generate.py --prompt "Same character but wearing a party hat" --reference images/character.png --output images/party.png
./scripts/generate.py --prompt "Gift basket containing items from reference images" --reference a.png --reference b.png --output basket.png
Landscape, high quality
./scripts/generate.py --prompt "Cinematic cyberpunk skyline" --size landscape --quality high --output skyline.png
Custom raw size
./scripts/generate.py --prompt "Abstract banner" --size 1920x1088 --output banner.png
Setup
Before first use, set up the virtual environment:
cd scripts && python3 -m venv venv && ./venv/bin/pip install -r requirements.txt
Set your API key:
export OPENAI_API_KEY="your-api-key-here"