$npx -y skills add GargantuaX/openskills --skill gpt-image-2Full OpenAI-compatible GPT Image 2 coverage across images/generations, images/edits, and responses with the image_generation tool. Use when the one-shot image helper is not enough - text-to-image, mask edits, multi-image batches, streaming, partial_images, and mixed text+image Re
| 1 | # GPT Image 2 |
| 2 | |
| 3 | A single Python entrypoint that covers every GPT Image 2 route, with strict pre-flight validation of the model's size, aspect, and feature constraints. |
| 4 | |
| 5 | ## Workflow |
| 6 | |
| 7 | 1. Open [references/config.md](./references/config.md) to pick environment variables and defaults. |
| 8 | 2. Open [references/api-surface.md](./references/api-surface.md) to choose between `generations`, `edits`, and `responses`. |
| 9 | 3. Prefer `OPENAI_BASE_URL=https://api.openai.com/v1` unless the user asks for a different OpenAI-compatible endpoint. |
| 10 | 4. Use `gpt-image-2` for `generations` and `edits`; use a text-capable Responses model such as `gpt-5.4` for `responses`. |
| 11 | 5. Run `scripts/gpt_image.py` with one of the three subcommands. |
| 12 | 6. Add `--dry-run` first when the payload shape is the main risk. |
| 13 | 7. Add `--save-response <path>` when the raw JSON body or SSE event stream needs to be kept for debugging. |
| 14 | |
| 15 | ## Commands |
| 16 | |
| 17 | Text-to-image through the public Images API: |
| 18 | |
| 19 | ```powershell |
| 20 | python .\skills\gpt-image-2\scripts\gpt_image.py generations ` |
| 21 | --prompt "A bold product hero image for a developer tool homepage" ` |
| 22 | --output .\out\hero.png ` |
| 23 | --size 1536x1024 ` |
| 24 | --quality high ` |
| 25 | --format png |
| 26 | ``` |
| 27 | |
| 28 | Multi-image batch with a filename pattern: |
| 29 | |
| 30 | ```powershell |
| 31 | python .\skills\gpt-image-2\scripts\gpt_image.py generations ` |
| 32 | --prompt "A cinematic city skyline at night" ` |
| 33 | --output .\out\skyline-{index}.webp ` |
| 34 | --n 3 ` |
| 35 | --format webp ` |
| 36 | --compression 90 |
| 37 | ``` |
| 38 | |
| 39 | Image edits with two inputs plus a mask: |
| 40 | |
| 41 | ```powershell |
| 42 | python .\skills\gpt-image-2\scripts\gpt_image.py edits ` |
| 43 | --prompt "Blend the two references into one clean marketing illustration" ` |
| 44 | --image .\refs\subject.png ` |
| 45 | --image .\refs\background.png ` |
| 46 | --mask .\refs\mask.png ` |
| 47 | --output .\out\edit-{index}.png ` |
| 48 | --image-field-style brackets ` |
| 49 | --n 2 |
| 50 | ``` |
| 51 | |
| 52 | Responses API with streaming and partial previews: |
| 53 | |
| 54 | ```powershell |
| 55 | python .\skills\gpt-image-2\scripts\gpt_image.py responses ` |
| 56 | --input-text "Generate a poster for an AI developer summit" ` |
| 57 | --model gpt-5.4 ` |
| 58 | --output .\out\poster-{index}.png ` |
| 59 | --stream ` |
| 60 | --partial-images 2 ` |
| 61 | --save-response .\out\poster-events.json |
| 62 | ``` |
| 63 | |
| 64 | Responses API edit with a local image plus a mask: |
| 65 | |
| 66 | ```powershell |
| 67 | python .\skills\gpt-image-2\scripts\gpt_image.py responses ` |
| 68 | --input-text "Turn this product shot into a clean studio ad" ` |
| 69 | --model gpt-5.4 ` |
| 70 | --input-image .\refs\product.png ` |
| 71 | --mask .\refs\mask.png ` |
| 72 | --output .\out\studio.png ` |
| 73 | --action edit |
| 74 | ``` |
| 75 | |
| 76 | Inspect the built request without sending it: |
| 77 | |
| 78 | ```powershell |
| 79 | python .\skills\gpt-image-2\scripts\gpt_image.py generations ` |
| 80 | --prompt "A minimal cover image" ` |
| 81 | --output .\out\cover.png ` |
| 82 | --dry-run |
| 83 | ``` |
| 84 | |
| 85 | ## Rules |
| 86 | |
| 87 | - Use `generations` for public text-to-image calls. |
| 88 | - Use `edits` for multipart image edits and mask uploads. |
| 89 | - Use `responses` for advanced flows: streaming, mixed text + image input, `previous_response_id`, `tool_choice`, `action`, and optional `tool_model`. |
| 90 | - Process environment variables override `.env`; CLI flags override both. |
| 91 | - Never print secrets. |
| 92 | - `--output` takes either a single path or a pattern such as `image-{index}.png` for multi-image or streaming flows. |
| 93 | - `responses` uses a top-level Responses model separate from the image model; default it to `gpt-5.4` unless you need another text-capable model. |
| 94 | - `quality` on Responses tool flows is passed through, but final behavior still depends on the hosted image tool. |
| 95 | - On OpenAI GPT image models, omit `response_format`; image data already comes back as base64. |
| 96 | - Fail fast on unsupported `gpt-image-2` combinations: transparent background, invalid size, `partial_images` outside `0..3`, or `stream=true` with `n>1` on public Images routes. |
| 97 | |
| 98 | ## Resources |
| 99 | |
| 100 | - Script: [scripts/gpt_image.py](./scripts/gpt_image.py) |
| 101 | - Config reference: [references/config.md](./references/config.md) |
| 102 | - API surface reference: [references/api-surface.md](./references/api-surface.md) |