Skip to main content
skill CX Codex

gpt-image-2 · gargantuax — Claude Code skill for image generation and edits

A Python skill that runs every GPT Image 2 route from the terminal. Covers text-to-image, mask edits, and the Responses API with streaming.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add GargantuaX/openskills --skill gpt-image-2 -a claude-code
Open on GitHub

What gpt-image-2 does

One script, three ways to work with GPT Image 2. generations makes images from a text prompt, edits handles several inputs plus a mask, and responses adds streaming, partial previews, and mixed text-and-image input.

The skill checks parameters before sending anything: size, aspect ratio, and what a given model supports. Bad combos like a transparent background or partial_images outside 0..3 fail fast, so you do not waste an API call on a request that would bounce.

Config comes from .env, process environment variables beat the file, and CLI flags beat both. --dry-run prints the request without sending it, and --save-response <path> keeps the raw JSON or SSE stream for debugging. Secrets never get printed.

You need Python and an API key in the environment. The default endpoint is https://api.openai.com/v1, but any OpenAI-compatible gateway works.

What it helps with

  • Generate an image from a text prompt
  • Edit an image using a mask
  • Create a batch of images in one run
  • Stream partial previews through the Responses API
  • Inspect a request before it reaches the API

Example prompts for the agent

  • Generate a hero image: python ./skills/gpt-image-2/scripts/gpt_image.py generations --prompt "A bold product hero image" --output ./out/hero.png --size 1536x1024
  • Run a masked edit: `python ./skills/gpt-image-2/scripts/gpt_image.py edits --prompt "Blend two references" --image ./refs/subject.png --image ./refs/background.png --mask ./refs/mask.png --output ./out/edit-{index}.png`
  • Check a request before sending it: python ./skills/gpt-image-2/scripts/gpt_image.py generations --prompt "Test" --output ./out/test.png --dry-run

How to install gpt-image-2

1Skills CLI (Vercel)

npx skills add GargantuaX/openskills --skill gpt-image-2 -a claude-code

2Manually: put the files in place

~/.claude/skills/gpt-image-2/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/gpt-image-2/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about gpt-image-2

How do I install gpt-image-2 in Claude Code?

Run npx skills add GargantuaX/openskills --skill gpt-image-2 -a claude-code. The skill lands in ~/.claude/skills/gpt-image-2/SKILL.md.

What does gpt-image-2 do?

It runs generation, editing, and Responses flows for GPT Image 2 from the command line. Parameters are validated before the request goes out, and any OpenAI-compatible gateway works.

How do generations and responses differ?

generations uses the public Images API for plain text-to-image. responses is a separate route for streaming, mixed input, and partial previews; it relies on a text-capable model such as gpt-5.4.

Source text

SKILL.md · MIT
---
name: gpt-image-2
description: Full 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 Responses flows. Reads .env and respects process environment variables; works with any OpenAI-compatible gateway.
---

# GPT Image 2

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.

## Workflow

1. Open [references/config.md](./references/config.md) to pick environment variables and defaults.
2. Open [references/api-surface.md](./references/api-surface.md) to choose between `generations`, `edits`, and `responses`.
3. Prefer `OPENAI_BASE_URL=https://api.openai.com/v1` unless the user asks for a different OpenAI-compatible endpoint.
4. Use `gpt-image-2` for `generations` and `edits`; use a text-capable Responses model such as `gpt-5.4` for `responses`.
5. Run `scripts/gpt_image.py` with one of the three subcommands.
6. Add `--dry-run` first when the payload shape is the main risk.
7. Add `--save-response <path>` when the raw JSON body or SSE event stream needs to be kept for debugging.

## Commands

Text-to-image through the public Images API:

```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py generations `
  --prompt "A bold product hero image for a developer tool homepage" `
  --output .\out\hero.png `
  --size 1536x1024 `
  --quality high `
  --format png
```

Multi-image batch with a filename pattern:

```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py generations `
  --prompt "A cinematic city skyline at night" `
  --output .\out\skyline-{index}.webp `
  --n 3 `
  --format webp `
  --compression 90
```

Image edits with two inputs plus a mask:

```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py edits `
  --prompt "Blend the two references into one clean marketing illustration" `
  --image .\refs\subject.png `
  --image .\refs\background.png `
  --mask .\refs\mask.png `
  --output .\out\edit-{index}.png `
  --image-field-style brackets `
  --n 2
```

Responses API with streaming and partial previews:

```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py responses `
  --input-text "Generate a poster for an AI developer summit" `
  --model gpt-5.4 `
  --output .\out\poster-{index}.png `
  --stream `
  --partial-images 2 `
  --save-response .\out\poster-events.json
```

Responses API edit with a local image plus a mask:

```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py responses `
  --input-text "Turn this product shot into a clean studio ad" `
  --model gpt-5.4 `
  --input-image .\refs\product.png `
  --mask .\refs\mask.png `
  --output .\out\studio.png `
  --action edit
```

Inspect the built request without sending it:

```powershell
python .\skills\gpt-image-2\scripts\gpt_image.py generations `
  --prompt "A minimal cover image" `
  --output .\out\cover.png `
  --dry-run
```

## Rules

- Use `generations` for public text-to-image calls.
- Use `edits` for multipart image edits and mask uploads.
- Use `responses` for advanced flows: streaming, mixed text + image input, `previous_response_id`, `tool_choice`, `action`, and optional `tool_model`.
- Process environment variables override `.env`; CLI flags override both.
- Never print secrets.
- `--output` takes either a single path or a pattern such as `image-{index}.png` for multi-image or streaming flows.
- `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.
- `quality` on Responses tool flows is passed through, but final behavior still depends on the hosted image tool.
- On OpenAI GPT image models, omit `response_format`; image data already comes back as base64.
- 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.

## Resources

- Script: [scripts/gpt_image.py](./scripts/gpt_image.py)
- Config reference: [references/config.md](./references/config.md)
- API surface reference: [references/api-surface.md](./references/api-surface.md)

© GargantuaX · MIT · GargantuaX/openskills

Similar skills

Everything for AI and ML →

gpt-image-2 by other authors comes first.

gpt-image-2 prime-skills Generates and edits images via OpenAI GPT Image 2 on RunComfy. Embeds text, logos, and multilingual typography accurately — for e-commerce, ads, and UI mockups. CX Codex +1 84,300installs gpt-image-2 pilioai A skill that wires Claude Image 2 into your agent through the Pilio API: text-to-image, prompt-based edits, restyling and reference composition. CX Codex +1 20,300installs skill-creator official anthropics Creates and refines skills, then tests them with prompts, evaluations, and performance checks. 414,180installs writing-for-agents Matt Pocock Guidance for writing skills and agent-facing documents. Use it when editing AGENTS.md, CLAUDE.md, or reference files reached from them. 466,719installs media-use heygen-com Finds or generates media for HyperFrames videos, including voiceovers, music, cutouts, and color grades. Stores files locally in assets. CX Codex +1 1,100,000installs mcp-builder official anthropics This skill walks through building an MCP server in TypeScript or Python, from reading the protocol spec to writing tests and evaluation questions. 130,949installs subagent-driven-development Jesse Vincent This skill runs an implementation plan through fresh subagents for independent tasks and reviews each result. Use it for multi-step work in one session. CX Codex 237,746installs orchestration stablyai Coordinates supervised Orca workers with task DAGs, decision gates, and threaded messages. Fits workflows that split work across multiple agents. CX Codex +1 349,800installs

From the same set2

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor