Gpt Image 2 Skill
- Installs
- 16.8k
- Repo stars
- 7
- Security scans passed
- 3/3
- Repo updated
- Apr 22, 2026
TL;DR
GPT Image 2 is a skill providing complete coverage of OpenAI's image generation, editing, and Responses APIs with validation and streaming.
Install if
Developers building image generation features; teams integrating OpenAI image APIs
Skip if
Projects not using OpenAI or OpenAI-compatible APIs
npx skills add https://github.com/GargantuaX/openskills --skill gpt-image-2Try it first through the Skillselion MCP - nothing to install, nothing on disk.
1. Add the remote connector:
claude mcp add --transport http skillselion https://mcp.skillselion.com/mcp2. Ask your agent:
Use Skillselion load_skill to load skill:gargantuax/openskills#gpt-image-2 (Gpt Image 2) and follow it.Try it first through the Skillselion MCP - nothing to install, nothing on disk.
1. Add this URL as a custom connector (Claude.ai, ChatGPT or Cursor):
https://mcp.skillselion.com/mcp2. Ask your agent:
Use Skillselion load_skill to load skill:gargantuax/openskills#gpt-image-2 (Gpt Image 2) and follow it.What gpt-image-2 covers
- Three API routes: text-to-image generations, image edits with masks, Responses API with streaming
- Strict pre-flight validation of model size, aspect, and feature constraints
- Multi-image batching, partial image streaming, and mixed text+image Responses flows
gpt-image-2 by the numbers
| All-time installs | 16,842 (16.8k) | skills.sh registry |
|---|---|---|
| Repo stars | ★ 7 | GitHub |
| Security audit | 3 / 3 scanners passed | skills.sh audit |
| Repo last updated | April 22, 2026 | GitHub |
| Repository | GargantuaX/openskills ↗ | |
Data as of Nov 16, 2026 (Skillselion catalog sync)
What can the gpt-image-2 skill do in Claude Code?
- Capabilities
- image generation · image editing · streaming · batch processing · api integration
- Works with
- openai
- Use cases
- image generation
What gpt-image-2 says it does
Full OpenAI-compatible GPT Image 2 coverage across images/generations, images/edits, and responses with the image_generation tool.
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.
What does the Gpt Image 2 skill produce?
Generated images, edited image files, streamed partial previews, and responses API image_generation tool outputs.
- Generated image files
- Edited image outputs
- Streaming image streams
- Covers 3 API routes: generations, edits, responses
- Supports up to 3 partial images in streaming
What files ship with gpt-image-2?
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
- Open references/config.md to pick environment variables and defaults.
- Open references/api-surface.md to choose between
generations,edits, andresponses. - Prefer
OPENAI_BASE_URL=https://api.openai.com/v1unless the user asks for a different OpenAI-compatible endpoint. - Use
gpt-image-2forgenerationsandedits; use a text-capable Responses model such asgpt-5.4forresponses. - Run
scripts/gpt_image.pywith one of the three subcommands. - Add
--dry-runfirst when the payload shape is the main risk. - 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:
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 pngMulti-image batch with a filename pattern:
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 90Image edits with two inputs plus a mask:
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 2Responses API with streaming and partial previews:
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.jsonResponses API edit with a local image plus a mask:
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 editInspect the built request without sending it:
python .\skills\gpt-image-2\scripts\gpt_image.py generations `
--prompt "A minimal cover image" `
--output .\out\cover.png `
--dry-runRules
- Use
generationsfor public text-to-image calls. - Use
editsfor multipart image edits and mask uploads. - Use
responsesfor advanced flows: streaming, mixed text + image input,previous_response_id,tool_choice,action, and optionaltool_model. - Process environment variables override
.env; CLI flags override both. - Never print secrets.
--outputtakes either a single path or a pattern such asimage-{index}.pngfor multi-image or streaming flows.responsesuses a top-level Responses model separate from the image model; default it togpt-5.4unless you need another text-capable model.qualityon 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-2combinations: transparent background, invalid size,partial_imagesoutside0..3, orstream=truewithn>1on public Images routes.
Resources
- Script: scripts/gpt_image.py
- Config reference: references/config.md
- API surface reference: references/api-surface.md
interface:
display_name: "GPT Image 2"
short_description: "Complete GPT Image 2 skill for generations, edits, and responses."
default_prompt: "Use $gpt-image-2 to generate, edit, or stream GPT Image 2 outputs through an OpenAI-compatible API."
gpt-image-2
An agent skill for the full GPT Image 2 surface on any OpenAI-compatible gateway. One Python entrypoint covers images/generations, images/edits, and responses (with the image_generation tool), including streaming and partial-image previews.
Built for Codex, Claude, and other skill-aware agents, but the script also runs fine by hand.
Features
- Three subcommands in one CLI:
generations,edits,responses. - Text-to-image, multi-image batches, mask edits, multi-reference edits, mixed text + image input.
- Streaming (SSE) with optional
partial_imagesprogressive previews. - Strict pre-flight validation of GPT Image 2 constraints (size, aspect, pixel count, transparent background,
output_compression,stream+n, and unsupportedresponse_formatusage on OpenAI GPT image models). - Automatic base64 de-duplication and multi-image filename templating (
out-{index}.png). - Config via CLI flags, process environment, or
.env— with a predictable override order. - Zero third-party dependencies (standard library only).
Requirements
- Python 3.10+
- An OpenAI-compatible endpoint that serves
gpt-image-2(default:https://api.openai.com/v1). - For
responses, a text-capable Responses model such asgpt-5.4when using the hostedimage_generationtool. OPENAI_API_KEY.
Install
After publishing the repository, the recommended install path is through Skills:
pnpm dlx skills add https://github.com/GargantuaX/openskills --skill gpt-image-2Equivalent shorthand:
pnpm dlx skills add GargantuaX/openskills@gpt-image-2If you want the whole collection instead, install:
pnpm dlx skills add GargantuaX/openskillsYou can also drop the folder into your agent's skill directory, or clone/copy it anywhere and invoke the script directly.
Register with Codex by pointing at agents/openai.yaml. Claude-style agents can consume SKILL.md directly.
Setup After skills.sh Install
- Set credentials with environment variables, or create a
.envin the working directory where you will run the script. - Start from the repository example `.env.example`, then adjust values for your endpoint and model defaults.
- Run a
--dry-runcommand first to confirm the final request shape before making live requests.
Minimal .env:
OPENAI_API_KEY=your-openai-api-key
OPENAI_BASE_URL=https://api.openai.com/v1
OPENAI_IMAGE_MODEL=gpt-image-2
OPENAI_RESPONSES_MODEL=gpt-5.4
OPENAI_IMAGE_SIZE=auto
OPENAI_IMAGE_QUALITY=high
OPENAI_IMAGE_FORMAT=webp
OPENAI_IMAGE_TIMEOUT=300Dry-run check:
python .\scripts\gpt_image.py responses `
--input-text "Generate a poster for an AI tool launch" `
--output .\out\poster.webp `
--dry-runQuick start
# 1. Configure credentials (either export or put in .env next to the script)
$env:OPENAI_API_KEY = "sk-..."
$env:OPENAI_BASE_URL = "https://api.openai.com/v1"
# 2. Generate
python .\scripts\gpt_image.py generations `
--prompt "A bold product hero image" `
--output .\out\hero.webpBuilt-in defaults now match the example .env: size=auto, quality=high, format=webp, timeout=300. For responses, the default top-level model is gpt-5.4; OPENAI_IMAGE_MODEL only applies to generations and edits.
See SKILL.md for the full command catalog, including multi-image batches, masked edits, and streaming Responses.
Project layout
gpt-image-2/
├─ SKILL.md # Agent-facing entry point (workflow + examples + rules)
├─ README.md # You are here
├─ agents/
│ └─ openai.yaml # Codex registration metadata
├─ references/
│ ├─ api-surface.md # When to use generations vs edits vs responses
│ └─ config.md # Environment variables and resolution order
└─ scripts/
└─ gpt_image.py # Single entrypoint, stdlib onlyConfiguration
All options can be set via CLI flags, process environment variables, or a .env file. Full table and resolution rules in references/config.md.
Runtime Notes
OPENAI_IMAGE_MODELcontrolsgenerationsandedits.OPENAI_RESPONSES_MODELcontrols the top-level model forresponses.OPENAI_IMAGE_TOOL_MODELoptionally overrides the hosted image model inside theimage_generationtool.- CLI flags override environment variables, and environment variables override
.env. .envis resolved from the current working directory unless you pass--env-file.- For OpenAI-hosted GPT image requests, omit
response_format.
Dry run
Add --dry-run to any command to print the exact request that would be sent (URL, headers, JSON payload, or multipart preview) without calling the API. Handy for agents that want to validate a plan before spending tokens or credits.
Tests
Run the local regression tests with:
python -m unittest discover -s .\skills\gpt-image-2\tests -p "test_*.py"These tests stay offline and focus on argument validation plus --dry-run request shapes.
Troubleshooting
Missing OPENAI_API_KEY— set it in the environment or in.env.gpt-image-2 requires width and height to be multiples of 16— adjust--size.Public Images routes do not support stream=true with n>1— useresponsesinstead, or drop--n.OpenAI GPT image models return base64 image data by default. Omit response_format.— remove--response-formatfor OpenAI-hosted GPT image requests.For responses with the image_generation tool, use a text-capable Responses model such as gpt-5.4— do not reusegpt-image-2as the top-levelresponsesmodel.output_compression is only valid with output_format jpeg or webp— set--format jpegor--format webp.partial_images requires stream=true— add--stream.
License
MIT. See the repository root LICENSE.
API Surface
Run scripts/gpt_image.py with one of these subcommands. Each one targets a different OpenAI-compatible route and has its own constraint set.
generations
Target route: POST /v1/images/generations
Use for:
- Text-to-image
- Public Images API compatibility checks
- Multi-image batches via
--n - Public-route streaming and
--partial-images
Constraints:
--promptis required.--nmust be in1..10.- On OpenAI GPT image models, omit
--response-formatentirely. background=transparentis rejected.--streamtogether with--n > 1is rejected.
edits
Target route: POST /v1/images/edits
Use for:
- Multipart image edits
- Multiple uploaded source images
- Mask uploads
- Public Images API edit compatibility checks
Constraints:
--promptis required.- At least one
--imagemust be provided. - Repeated image field style can be
simple,brackets, orindexed;bracketsmatches OpenAI's documented multipart shape. background=transparentis rejected.- On OpenAI GPT image models, omit
--response-formatentirely. --streamtogether with--n > 1is rejected.
responses
Target route: POST /v1/responses
Use for:
- Advanced image workflows
- Streaming-first flows
- Mixed text + image input
previous_response_idtool_choiceaction- Image inputs from local files, URLs, data URLs, or file references
Constraints:
- Uses a text-capable Responses model at the top level (default:
gpt-5.4). - Sends an
image_generationtool by default. - Supports
--mask,--mask-url, and--mask-file-id. --tool-modeloptionally overrides the hosted image model for the tool.--tool-choice image_generationis normalized to{"type":"image_generation"}.--input-fidelityis only valid for supported non-gpt-image-2tool models.qualityis passed through to the hosted image tool.- Local image files are converted to data URLs before being sent.
Shared GPT Image 2 validation
The script runs these checks before every request:
- Size must be
autoorWIDTHxHEIGHT. - Width and height must be multiples of
16. - Longest edge must be
<= 3840. - Aspect ratio must be
<= 3:1. - Total pixels must be in
655360..8294400. - Transparent background is not supported.
output_compressionmust stay in0..100and only applies tojpegorwebp.partial_imagesmust be in0..3and requiresstream=true.
Config
Environment variables consumed by scripts/gpt_image.py:
| Variable | Required | Default | Purpose |
|---|---|---|---|
OPENAI_API_KEY | yes | none | API key for the OpenAI-compatible endpoint |
OPENAI_BASE_URL | no | https://api.openai.com/v1 | Base URL, must include /v1 |
OPENAI_IMAGE_MODEL | no | gpt-image-2 | Default model for generations and edits |
OPENAI_RESPONSES_MODEL | no | gpt-5.4 | Default top-level model for responses |
OPENAI_IMAGE_TOOL_MODEL | no | unset | Optional hosted image model override for the responses image tool |
OPENAI_IMAGE_TIMEOUT | no | 300 | HTTP timeout in seconds |
OPENAI_IMAGE_SIZE | no | auto | e.g. 1024x1024, 1536x1024, auto |
OPENAI_IMAGE_QUALITY | no | high | auto, low, medium, high |
OPENAI_IMAGE_BACKGROUND | no | unset | auto or opaque |
OPENAI_IMAGE_FORMAT | no | webp | png, jpeg, webp |
OPENAI_IMAGE_COMPRESSION | no | unset | 0..100, only for jpeg or webp |
OPENAI_IMAGE_MODERATION | no | unset | auto or low |
OPENAI_IMAGE_USER | no | unset | Optional OpenAI-compatible user field |
OPENAI_IMAGE_N | no | 1 | Default image count for generations and edits |
OPENAI_IMAGE_RESPONSE_FORMAT | no | unset | Legacy compatibility field for non-GPT image models; omit it for OpenAI GPT image models |
OPENAI_IMAGE_STREAM | no | false | Default streaming flag |
OPENAI_IMAGE_PARTIAL_IMAGES | no | unset | 0..3, used together with streaming |
OPENAI_IMAGE_INPUT_FIDELITY | no | unset | Optional input_fidelity for supported tool models in responses |
OPENAI_IMAGE_TOOL_CHOICE | no | image_generation | Default tool_choice for responses; the script maps this to {\"type\":\"image_generation\"} |
Resolution order:
- CLI flags
- Process environment variables
.envfile- Built-in defaults
.env lookup:
--env-file <path>when provided- Search from
<cwd>/.envupward through parent directories until the first.envis found
Minimal .env example:
OPENAI_API_KEY=sk-example
OPENAI_BASE_URL=https://api.openai.com/v1
OPENAI_IMAGE_MODEL=gpt-image-2
OPENAI_RESPONSES_MODEL=gpt-5.4
OPENAI_IMAGE_SIZE=auto
OPENAI_IMAGE_QUALITY=high
OPENAI_IMAGE_FORMAT=webp
OPENAI_IMAGE_TIMEOUT=300Notes:
OPENAI_BASE_URLmust already include/v1.OPENAI_IMAGE_MODELdoes not control the top-level model forresponses; useOPENAI_RESPONSES_MODELfor that.OPENAI_IMAGE_STREAM=trueis valid for all three subcommands, but public Images routes still rejectstream=truetogether withn>1.- On OpenAI GPT image models, omit
OPENAI_IMAGE_RESPONSE_FORMATentirely. OPENAI_IMAGE_INPUT_FIDELITYis not configurable forgpt-image-2.- Process environment variables override
.env, so local shell overrides stay predictable.
import json
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path
SCRIPT_PATH = Path(__file__).resolve().parents[1] / "scripts" / "gpt_image.py"
class GptImageCliTest(unittest.TestCase):
def run_cli(self, *args: str, cwd: str | None = None) -> subprocess.CompletedProcess[str]:
with tempfile.TemporaryDirectory() as tmpdir:
workdir = cwd or tmpdir
return subprocess.run(
[sys.executable, str(SCRIPT_PATH), *args],
cwd=workdir,
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
env={},
check=False,
)
def test_responses_dry_run_uses_responses_model_and_object_tool_choice(self) -> None:
result = self.run_cli(
"responses",
"--input-text",
"Generate a poster",
"--output",
"poster.png",
"--dry-run",
)
self.assertEqual(result.returncode, 0, result.stderr)
payload = json.loads(result.stdout)
request = payload["request"]
self.assertEqual(request["model"], "gpt-5.4")
self.assertEqual(request["tool_choice"], {"type": "image_generation"})
self.assertEqual(request["tools"][0]["type"], "image_generation")
self.assertEqual(request["tools"][0]["size"], "auto")
self.assertEqual(request["tools"][0]["quality"], "high")
self.assertEqual(request["tools"][0]["output_format"], "webp")
def test_generations_rejects_response_format_for_gpt_image_models(self) -> None:
result = self.run_cli(
"generations",
"--prompt",
"test",
"--output",
"test.png",
"--response-format",
"b64_json",
"--dry-run",
)
self.assertNotEqual(result.returncode, 0)
self.assertIn("Omit response_format", result.stderr)
def test_responses_rejects_gpt_image_model_as_top_level_model(self) -> None:
result = self.run_cli(
"responses",
"--model",
"gpt-image-2",
"--input-text",
"Generate a poster",
"--output",
"poster.png",
"--dry-run",
)
self.assertNotEqual(result.returncode, 0)
self.assertIn("text-capable Responses model", result.stderr)
def test_responses_rejects_input_fidelity_for_default_gpt_image_2_tool(self) -> None:
result = self.run_cli(
"responses",
"--input-text",
"Generate a poster",
"--input-fidelity",
"high",
"--output",
"poster.png",
"--dry-run",
)
self.assertNotEqual(result.returncode, 0)
self.assertIn("not configurable for gpt-image-2", result.stderr)
def test_responses_accepts_supported_tool_model_with_input_fidelity(self) -> None:
result = self.run_cli(
"responses",
"--input-text",
"Generate a poster",
"--tool-model",
"gpt-image-1.5",
"--input-fidelity",
"high",
"--output",
"poster.png",
"--dry-run",
)
self.assertEqual(result.returncode, 0, result.stderr)
payload = json.loads(result.stdout)
tool = payload["request"]["tools"][0]
self.assertEqual(tool["model"], "gpt-image-1.5")
self.assertEqual(tool["input_fidelity"], "high")
def test_dry_run_finds_dotenv_in_parent_directory(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
root = Path(tmpdir)
nested = root / "a" / "b"
nested.mkdir(parents=True)
(root / ".env").write_text(
"\n".join(
[
"OPENAI_BASE_URL=http://parent-env.example/v1",
"OPENAI_IMAGE_QUALITY=medium",
]
),
encoding="utf-8",
)
result = self.run_cli(
"generations",
"--prompt",
"test",
"--output",
"test.png",
"--dry-run",
cwd=str(nested),
)
self.assertEqual(result.returncode, 0, result.stderr)
payload = json.loads(result.stdout)
request = payload["request"]
self.assertEqual(payload["url"], "http://parent-env.example/v1/images/generations")
self.assertEqual(request["quality"], "medium")
if __name__ == "__main__":
unittest.main()
Which skills are related to gpt-image-2?
Gpt Image 2 skill FAQ
Who is the Gpt Image 2 skill for?
Developers building image generation features; teams integrating OpenAI image APIs. Skip if: Projects not using OpenAI or OpenAI-compatible APIs.
When should I use gpt-image-2?
The user asks to generate, edit, or stream GPT Image 2 images via OpenAI-compatible API inside an agent session.
What are the three API routes?
generations for text-to-image, edits for multipart image editing with masks, and responses for advanced flows with streaming and mixed text+image input.
Do I need to handle constraints manually?
No - the script includes strict pre-flight validation of model size, aspect ratio, and feature constraints.
Is Gpt Image 2 safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
Add a gpt-image-2 badge
Show developers this skill is listed on Skillselion. Paste this into your README.