/gpt-image-2-skill:gpt-image-2-skillfrom gpt-image-2-skill
Generates and edits images via GPT Image CLI, supporting transparent PNGs, SVG, GIF, masks, and raw requests. Returns JSON results with progress events. Useful for programmatic image generation and editing with OpenAI or compatible providers.
Ships in gpt-image-2-skill. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Run image generation and editing through one CLI surface that hides provider differences. The Node wrapper at scripts/gpt_image_2_skill.cjs resolves an underlying Rust binary (env override → bundled Skill binary → installed binary → Tauri App bundled CLI → repo cargo run → cached release → bootstrap download) and forwards every flag. On glibc Linux, release bootstrap tries the GNU archive first and then the static musl archive as the sandbox fallback.
使用新参数、2.6 模型或新的默认绘图行为时,wrapper 会先读取运行时的 models list,跳过缺少所需能力的旧 CLI;显式 GPT_IMAGE_2_SKILL_BIN 指向旧版时返回 runtime_outdated,不会替换用户指定的二进制文件。显式旧模型和普通 Codex 命令保留兼容性。未发版源码请先构建 CLI,再通过该变量指向本地二进制文件。
OPENAI_API_KEY, an OpenAI-compatible base URL, and Codex auth.json without changing command shape.$CODEX_HOME/gpt-image-2-skill/config.json so CLI, App, and Skill use the same default provider.Always pass --json so the result is machine-readable. Add --json-events when progress visibility matters.
# 1. Confirm runtime + provider readiness
node scripts/gpt_image_2_skill.cjs --json config inspect
node scripts/gpt_image_2_skill.cjs --json doctor
node scripts/gpt_image_2_skill.cjs --json auth inspect
# 2. Generate a final transparent PNG deliverable
node scripts/gpt_image_2_skill.cjs --json --json-events \
transparent generate --prompt "..." --out /tmp/asset.png \
--size 2K --quality high
# 3. Generate a normal image (auto-selects provider; OpenAI first, then Codex)
node scripts/gpt_image_2_skill.cjs --json --json-events \
images generate --prompt "..." --out /tmp/out.png \
--format png --size 2K
# 4. Edit a reference image (OpenAI multipart)
node scripts/gpt_image_2_skill.cjs --json --json-events \
images edit --prompt "..." --ref-image /tmp/in.png --out /tmp/out.png
# 5. Remove a controlled background from existing source images
node scripts/gpt_image_2_skill.cjs --json \
transparent extract --input /tmp/source-green.png --out /tmp/asset.png \
--method chroma --matte-color auto --strict
# 6. Verify the final file before delivery
node scripts/gpt_image_2_skill.cjs --json \
transparent verify --input /tmp/asset.png --profile icon --strict
# 7. Raw request escape hatch
node scripts/gpt_image_2_skill.cjs --json \
request create --request-operation generate \
--body-file /tmp/body.json --out-image /tmp/out.png --expect-image
# 8. Self-test (calls doctor + auth inspect)
node scripts/selftest.cjs
Force a provider with --provider openai, --provider codex, or any named provider from config inspect; leave the default --provider auto to use default_provider first. Override the legacy OpenAI base URL with --openai-api-base https://....
以下 CLI 示例走 Responses 路径。复现最新 Codex App 时,应区分宿主原生 image_gen.imagegen 的独立 Images 路径;见 references/codex-native-imagegen.md。原生工具成功不代表 CLI 已适配,服务端别名也不能证明实际权重版本。
用户指定 Codex 时,必须显式传 --provider codex,避免共享配置将请求路由到 OpenAI-compatible 服务。下面的命令从 Skill 目录执行,使用本地 Codex 登录,不需要 OpenAI API key:
node scripts/gpt_image_2_skill.cjs --json --provider codex doctor
mkdir -p output
node scripts/gpt_image_2_skill.cjs --json --json-events --provider codex \
images generate --model gpt-6-astra \
--prompt "一只橙色纸雕小狐狸坐在蓝绿色月牙上,深蓝背景" \
--out output/codex-fox.png --format png --size 1024x1024 \
> output/result.json 2> output/events.jsonl
gpt-5.4;本地实测已被 ChatGPT 账户后端拒绝。示例显式使用本次验证的 gpt-6-astra,其他账户仍需核对可用模型。--model 是外层调用工具的模型,不能填 gpt-image-2.5-flare 或 gpt-image-2.5-sunburst。这两个是图像模型 ID。tools[].model,由 Codex 服务端选择绘图模型。读取 类型为 response.created 的 SSE 日志中 data.response.tools[].model;不要将 CLI 摘要的 delegated_image_model 当作实测结果,该字段在当前版本仍硬编码为 gpt-image-2。ok: true、图片文件真实存在且经过视觉检查,才能报告生图成功。请求被接受或进入 generating 不能视为完成。references/codex-local-verification.md。OpenAI Images API 的默认模型为 gpt-image-2.6-sunburst,适合细致绘图与编辑;快速迭代可显式选择 gpt-image-2.6-flare。--model 和共享配置中已固定的模型优先,不自动降级或切换 provider。项目名称和命令名仍为 gpt-image-2-skill。
--complexity low|medium|high 控制绘制前的规划,独立于 --quality;省略时上游默认 high。草稿可用 --quality low --complexity low。images edit --markup <透明PNG> 传独立标注层,不能同时使用 --mask。CLI 会检查透明像素及与首张原图在方向校正后的尺寸一致性。--format svg 仅用于 images generate,且 --n 1。默认不发送 SVG 作者配置;只有账户支持作者模型选择且用户需要时,才加 --svg-model 和可选的 --svg-reasoning-effort。SVG 作者 token 单独计费,见 response.svg_usage。--format gif 用于生成或编辑,配合 --frame-count 2..16、--frame-duration-ms。帧尺寸支持 256x256 等较小尺寸,不能套用静态图的最低像素限制。node scripts/gpt_image_2_skill.cjs --json --provider openai images generate \
--model gpt-image-2.6-flare --prompt "一枚蓝色纸雕月亮图标" \
--quality low --complexity low --format png --out /tmp/moon.png
node scripts/gpt_image_2_skill.cjs --json --provider openai images generate \
--model gpt-image-2.6-sunburst --prompt "小灯笼轻轻摇摆,无缝循环" \
--format gif --size 640x640 --frame-count 2 --frame-duration-ms 200 \
--quality low --complexity low --out /tmp/lantern.gif
完整格式限制、SVG 作者配置和 markup 工作流见 references/image-2.6.md。官方依据:2.6 Sunburst、2.6 Flare、图像生成指南。
OpenAI 官方已列出 gpt-image-2.5-flare 和 gpt-image-2.5-sunburst,可在 OpenAI Image API 中使用 --model 显式选择;这不代表 Codex 订阅后端已支持相同模型选择。保留用户指定的模型和共享配置。
2.5 的公共 API 支持 xhigh / max 质量和原生透明 PNG/WebP,当前 Rust CLI 与桌面生成界面已支持 low|medium|high|xhigh|max|auto;xhigh/max 仅用于支持它们的 API 模型,不能保证 Codex 订阅后端支持。Codex 的原始请求操作必须是 responses,不能用 generate。
Before using newly documented command groups, especially transparent generate, transparent extract, or transparent verify, confirm the actual CLI runtime is fresh enough. Skill files, the Tauri App bundle, npm global CLI, cargo-installed CLI, and wrapper cache can drift independently.
Start by checking the latest upstream CLI version:
npm view gpt-image-2-skill version
版本号检查后还须运行 node scripts/gpt_image_2_skill.cjs --json models list,确认 providers.openai.supports 含 complexity、markup、frame_count 和 svg。源码与已发布的相同版本号可能具有不同能力;不能仅凭版本号认定 2.6 已就绪。出现 runtime_outdated 时构建或安装支持这些能力的 CLI,不要改用旧参数掩盖失败。
Then look for the Tauri App bundled CLI first. Treat the app bundle as user-managed software: if it exists but is older than upstream, ask the user before updating or replacing the app.
APP_CLI="/Applications/GPT Image 2.app/Contents/Resources/bin/gpt-image-2-skill"
[ -x "$APP_CLI" ] && "$APP_CLI" --version
If no app bundle CLI exists, check the shell CLI. If it is missing or older than upstream, silently update the CLI dependency with npm, then verify that the current shell resolves the new binary:
command -v gpt-image-2-skill || true
gpt-image-2-skill --version || true
npm install -g gpt-image-2-skill@latest
command -v gpt-image-2-skill
gpt-image-2-skill --version
After any update, run the skill wrapper smoke checks:
node scripts/gpt_image_2_skill.cjs --json doctor
node scripts/selftest.cjs
If a documented subcommand fails with unrecognized subcommand, diagnose stale runtime first rather than changing prompts or providers. Prefer the wrapper in this skill directory for reproducible skill execution, but keep the bare CLI fresh when examples or user commands call gpt-image-2-skill directly.
Use the CLI config surface when the user asks to add or pin a provider:
node scripts/gpt_image_2_skill.cjs --json config path
node scripts/gpt_image_2_skill.cjs --json config add-provider \
--name my-image-api \
--type openai-compatible \
--api-base https://example.com/v1 \
--api-key sk-... \
--set-default
node scripts/gpt_image_2_skill.cjs --json config test-provider my-image-api
Credential sources supported by CLI, App, and Skill: file, env, and keychain. File credentials are stored in the shared config file; JSON output redacts them.
输出属性优先通过接口参数表达,但 Codex 后端可能归一化或忽略参数。提示词可表达期望,最终必须读取实际返回值并检查图片;不要将任何单一参数或提示词视为执行保证。
| Property | CLI flag |
|---|---|
| Output background (transparent / opaque / auto) | --background auto|transparent|opaque |
| Output dimensions | --size 2K, --size 4K, or --size WIDTHxHEIGHT |
| Output container | --format png|jpeg|webp|gif|svg(GIF/SVG 为 Images API) |
| Compression level | --compression 0..100 |
| Render quality | --quality low|medium|high|xhigh|max|auto |
| 绘制规划 | --complexity low|medium|high(2.6 Images API) |
| Number of images | --n <count> (OpenAI only) |
| Edit mask region | --mask <png> (OpenAI only) |
| 标注层编辑 | --markup <透明PNG>(Images API,与 mask 互斥) |
| 动画帧 | --frame-count 2..16 --frame-duration-ms <毫秒>(GIF) |
提示词用于内容与视觉意图;--background opaque 只表达不透明,不指定白色。白背景还需在提示词中明确。对于 Codex,透明提示词配合 background=auto 可能得到真实 alpha,而显式透明参数当前可能报错;以实测和文件检查为准。
Provider asymmetry: --n, --moderation, --mask 和 --input-fidelity 在 Codex 普通命令中返回 unsupported_option。--background 会写入 Codex 请求,但不能据此保证上游执行;本次原始透明背景请求被后端拒绝。公共 Image API 与 Codex 后端的能力必须分别验证。
Codex 的显式 background=transparent 在本地对照中被拒绝,但 background=auto 配合透明提示词曾成功生成真实 RGBA。可以将后者作为候选路径,必须验证 alpha 和严格交付指标;本次样本因全透明区域残留 RGB 未通过严格验收。已合格的原生透明图无需再次抠图。需要本地处理时使用下列流程;OpenAI 2.5 公共 API 的原生透明输出也需同样验收:
transparent generate — prompt-to-final PNG. It generates a controlled matte source, extracts alpha locally, verifies the result, and only succeeds when the final PNG passes transparency checks.transparent extract — local background removal from controlled source images you generated yourself. It is not a general-purpose background remover for arbitrary photos.transparent verify — final gate for any PNG before delivery. Use --strict and the right --profile when the file must be accepted or fail the task.A transparent deliverable is valid only if the final file has a real PNG alpha channel and passes verification. A visual appearance of transparency, a white background, or a checkerboard pattern is not sufficient.
--strict is profile-based:
| Profile | Use for | Extra strictness |
|---|---|---|
generic | common alpha/file checks | does not over-police unusual assets |
icon | clean single-subject icons and props | requires clean opaque core, margin, low stray noise |
product | product/object cutouts | similar to icon, with residue and edge checks |
sticker | decals, badges, multi-detail props | allows more intentional small components than icon |
seal | stamps, seals, logos with inner marks | allows split components such as ring + center symbol |
translucent | glass, liquid, crystal | requires partial alpha |
glow | light ribbons, flame, smoke, particles | requires partial alpha and transparent margin |
shadow | soft shadow assets | requires partial alpha and transparent margin |
effect | hard-alpha particles, bursts, UI effects | transparent margin without requiring partial alpha |
The CLI is intentionally not a material classifier. The Agent should choose generation prompts and extraction methods based on the asset:
| Asset type | Generation guidance | Extraction guidance |
|---|---|---|
| Opaque object, icon, sticker, product | Single isolated subject, clear margin, perfectly flat chroma matte. Pick a matte color absent from the object. | transparent generate or transparent extract --method chroma --matte-color auto |
| Thin edges, hair, fur, lace, chain, netting | Use high resolution, strong subject/background contrast, no contact shadow, no background-colored details. Try magenta/cyan/green mattes if one contaminates the edge. | Chroma extraction with --spill-suppression when needed, then verify with --expected-matte-color; retry with a different matte if residue remains. |
| Glass, crystal, liquid, hologram | Ask for a centered asset on flat black and flat white backgrounds, keeping geometry identical. Use reference/edit flow when possible to keep alignment. | transparent extract --method dual --dark-image black.png --light-image white.png |
| Glow, flame, smoke, mist, magic particles | Generate dark and light background variants. Avoid textured backgrounds and avoid bloom reaching the image edge unless the edge is intentional. | Prefer dual extraction; verify that partial_pixels is non-zero. |
| Shadows | Decide whether the shadow is part of the asset. If not, explicitly forbid contact shadows. If yes, generate on a flat matte with enough margin. | Chroma for opaque shadow silhouettes; dual extraction for soft translucent shadows. |
| Unknown or unusual material | Do not classify it first. Generate controlled source variants, run extraction candidates, and keep the one that passes verification with the cleanest edge. | Use --report-dir / --keep-sources while iterating, then deliver only the final PNG. |
For chroma extraction, --matte-color auto samples the actual flat source background from the image edges. Prefer it when the source was AI-generated, because prompts like "pure #ff00ff" often produce near-matte colors rather than exact RGB values. Use explicit --matte-color <name|#rrggbb> only when the source background is known exactly.
For extraction tuning, use --material only as a broad hint, not as a subject classifier: standard, soft-3d, flat-icon, sticker, or glow. Manual --threshold, --softness, and --spill-suppression override the selected preset.
For style-locked transparent assets, transparent generate is prompt-only. Use a flat RGB reference image with images edit --ref-image to create a controlled matte source, then run transparent extract. Do not use a transparent PNG as the reference image unless you intentionally want the alpha/composited edge behavior to influence the edit.
GPT Image 2 can render accurate UI text, numbers, scores, labels, and logo marks in the bitmap when they are part of the desired artwork. Put the exact wording or numbering in the prompt and verify the output visually. Render text separately in the host app or design tool only when it must stay editable, localizable, programmatically changeable, or perfectly consistent across many generated variants.
Examples:
# Simple asset: final transparent PNG, sources hidden unless there is a failure
node scripts/gpt_image_2_skill.cjs --json --json-events \
transparent generate \
--prompt "a polished fantasy sword game asset, no text, no frame" \
--out /tmp/sword.png --size 2K --quality high
# Agent-controlled chroma flow
node scripts/gpt_image_2_skill.cjs --json --json-events \
images generate \
--prompt "a silver necklace, centered, on a perfectly flat pure magenta background, no shadow" \
--out /tmp/necklace-magenta.png --format png --size 2K
node scripts/gpt_image_2_skill.cjs --json \
transparent extract --method chroma \
--input /tmp/necklace-magenta.png --matte-color auto \
--out /tmp/necklace.png --material sticker --strict
# Semi-transparent material flow
node scripts/gpt_image_2_skill.cjs --json \
transparent extract --method dual \
--dark-image /tmp/glow-on-black.png \
--light-image /tmp/glow-on-white.png \
--out /tmp/glow.png --strict
Always inspect the JSON verification fields before delivery: passed, alpha_min, alpha_max, transparent_ratio, partial_pixels, and warnings. Also inspect quality fields: checkerboard_detected, touches_edge, edge_margin_px, stray_pixel_count, largest_component_ratio, matte_residue_checked, matte_residue_score, halo_score, transparent_rgb_scrubbed, alpha_health_score, residue_score, quality_score, and failure_reasons. If passed is false, do not deliver the file as a transparent PNG. If matte_residue_checked is false for a chroma-derived PNG, run transparent verify again with the source matte via --expected-matte-color.
gpt-image-2.6-sunburst / Codex gpt-5.4;Codex 使用上面的显式模型示例。公共 API 的 2.6 支持不证明 Codex 订阅后端支持同样能力。--size、--quality、--format、--compression;Codex 服务端可能归一化这些参数,应核对返回值和实际文件。--n, --moderation, --mask, --input-fidelity; Codex background behavior requires separate verification.401 triggers one token refresh + one retry.2K → 2048x2048, 4K → 3840x2160. Custom WxH requires both edges multiples of 16, max edge 3840, max 8,294,400 pixels, max aspect ratio 3:1.Load on demand for deeper detail:
references/codex-native-imagegen.md — App 原生工具、独立 Images 端点与旧 CLI 调用路径的区别。references/image-2.6.md — 2.6 模型、complexity、markup、SVG/GIF 参数与费用边界。references/codex-local-verification.md — 本地 Codex 生图命令、实测结果与模型识别边界。references/providers.md — OpenAI / OpenAI-compatible / Codex selection, auth sources, runtime discovery, update policy, and resolution order.references/sizes-and-formats.md — size aliases, custom constraints, format/quality/compression/background, shared vs OpenAI-only flags.references/transparent-png.md — Agent playbook for prompt design, controlled mattes, dual-background extraction, verification, and retry loops.references/json-output.md — --json stdout schema, success and error envelopes, per-command shapes.references/json-events.md — --json-events JSONL phases (request_started, multipart_prepared, retry_scheduled) and Codex SSE passthrough.references/troubleshooting.md — runtime_unavailable, auth_missing, Codex 401 refresh, retry policy, size rejections, moderation, timeouts.The companion file agents/openai.yaml is read by Codex Skill runtime only (Claude Code ignores it). Both runtimes execute the commands above with cwd at the skill directory, so relative paths like scripts/gpt_image_2_skill.cjs resolve in either harness.
agents/openai.yaml (opens in a new tab)evals/README.md (opens in a new tab)evals/evals.json (opens in a new tab)evals/trigger-eval.json (opens in a new tab)references/codex-local-verification.md (opens in a new tab)references/codex-native-imagegen.md (opens in a new tab)references/image-2.6.md (opens in a new tab)references/json-events.md (opens in a new tab)references/json-output.md (opens in a new tab)references/providers.md (opens in a new tab)references/sizes-and-formats.md (opens in a new tab)references/transparent-png.md (opens in a new tab)references/troubleshooting.md (opens in a new tab)scripts/gpt_image_2_skill.cjs (opens in a new tab)scripts/selftest.cjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (wangnov/gpt-image-2-skill) — no native marketplace selected
npx claudepluginhub p/wangnov-gpt-image-2-skillOther plugins' skills for the same job