$npx -y skills add mkdev-me/agent-skills --skill openai-image-generatorGenerate images using OpenAI gpt-image-2 with customizable options
| 1 | # openai-image-generator |
| 2 | |
| 3 | ## Instructions |
| 4 | |
| 5 | Use this skill to generate images using OpenAI's `gpt-image-2` model. The skill supports: |
| 6 | - Text-to-image generation from prompts (`images.generate`) |
| 7 | - Image editing / composition with one or more reference images (`images.edit`) |
| 8 | - Size presets (square, landscape, portrait, 2K) or a raw `WxH` string |
| 9 | - Quality levels (low / medium / high / auto) |
| 10 | - Custom output paths |
| 11 | |
| 12 | The API key should be set via the `OPENAI_API_KEY` environment variable. |
| 13 | |
| 14 | ## Parameters |
| 15 | |
| 16 | - `--prompt` (required): The text prompt describing the image to generate |
| 17 | - `--output` (required): Output file path for the generated image |
| 18 | - `--reference`: Optional reference image path. Can be specified multiple times. When provided, the edits endpoint is used. |
| 19 | - `--size`: Output size. Accepts a preset (`square`, `landscape`, `portrait`, `2K`) or a raw `WxH` string (e.g. `1920x1080`). Default: `square` (1024x1024). |
| 20 | - `--quality`: `low`, `medium`, `high`, or `auto` (default: `auto`) |
| 21 | |
| 22 | 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. |
| 23 | |
| 24 | ## Examples |
| 25 | |
| 26 | ### Basic text-to-image generation |
| 27 | ```bash |
| 28 | ./scripts/generate.py --prompt "A serene mountain landscape at sunset" --output images/landscape.png |
| 29 | ``` |
| 30 | |
| 31 | ### With reference image(s) for editing / composition |
| 32 | ```bash |
| 33 | ./scripts/generate.py --prompt "Same character but wearing a party hat" --reference images/character.png --output images/party.png |
| 34 | ``` |
| 35 | |
| 36 | ```bash |
| 37 | ./scripts/generate.py --prompt "Gift basket containing items from reference images" --reference a.png --reference b.png --output basket.png |
| 38 | ``` |
| 39 | |
| 40 | ### Landscape, high quality |
| 41 | ```bash |
| 42 | ./scripts/generate.py --prompt "Cinematic cyberpunk skyline" --size landscape --quality high --output skyline.png |
| 43 | ``` |
| 44 | |
| 45 | ### Custom raw size |
| 46 | ```bash |
| 47 | ./scripts/generate.py --prompt "Abstract banner" --size 1920x1088 --output banner.png |
| 48 | ``` |
| 49 | |
| 50 | ## Setup |
| 51 | |
| 52 | Before first use, set up the virtual environment: |
| 53 | ```bash |
| 54 | cd scripts && python3 -m venv venv && ./venv/bin/pip install -r requirements.txt |
| 55 | ``` |
| 56 | |
| 57 | Set your API key: |
| 58 | ```bash |
| 59 | export OPENAI_API_KEY="your-api-key-here" |
| 60 | ``` |