Generate or edit images with GPT Image 2 or 2.5 through the packaged CLI and Reference Gallery. Use for image requests including imprecise 'GPT 2.5' model names
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-gpt-image-49e85460aca4 ,按照其中的说明把「gpt-image」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Agent runbook for GPT Image 2 / 2.5 generation/editing. Use the prompt library + packaged CLI. Do not reimplement image API code.
generate, edit, inpaint, or multi-reference; identify asset type, exact text, aspect ratio, references, safety constraints, and budget/quality. Apply the model-choice rules below before any API call.command -v gpt-image), installed tool lists when the tool manager exists, or the runtime’s own skill registry when available. Do not assume a local home path in cloud/hosted runtimes..env, or write API keys unless the user explicitly requested setup. Global/shared installs are opt-in only.gpt-image or scripts/generate.py with an explicit --model. Do not create a new generate.py, SDK wrapper, or ad-hoc script for normal image requests.Fast path: confirmed 2.5 model + precise prompt + “generate now” → preflight and CLI, without a mandatory reference/craft pass. Do not reconfirm an exact valid model.
| Choice | API model ID | Suggested use |
|---|---|---|
| Flare | gpt-image-2.5-flare | Fast general generation and drafts |
| Sunburst | gpt-image-2.5-sunburst | Precise reference edits and detailed control |
| Image 2 | gpt-image-2 | Existing Image 2 workflows and compatibility |
gpt-image-2.5 as an API model ID.--model. The CLI retains gpt-image-2 as its backward-compatible default, but that default is not a substitute for the agent resolving the user's choice.references/models.md when parameter support or validation status needs checking. On an invalid-model, access/403, quota, or policy failure, report the failure and stop; do not switch models or rewrite the prompt to retry automatically.Preferred call order:
# Existing CLI on PATH
gpt-image --model MODEL_ID -p "PROMPT" [-f OUT] [-i REF...] [-m MASK] [options]
# Installed skill folder; use runtime-provided skill path when available
uv run "$SKILL_DIR/scripts/generate.py" --model MODEL_ID -p "PROMPT" [-f OUT] [-i REF...] [-m MASK] [options]
# Direct transient CLI when the user requested setup/one-off CLI execution
uvx --from git+https://github.com/wuyoscar/gpt_image_2_skill gpt-image --model MODEL_ID -p "PROMPT" [options]
scripts/generate.py is a launcher: repo-local src/gpt_image_cli → installed gpt-image → PATH gpt-image → transient uvx/uv fallback.
OPENAI_API_KEY from process env, then .env, then ~/.env without overriding existing env; successful API calls may bill the user’s OpenAI account.OPENAI_API_KEY is unset, report missing key or use host-native generation when requested; do not write secrets.unset OPENAI_API_KEY; if a key exists in .env/~/.env, tell them to remove/rename it for the session rather than working around it.| Flag | Values | Use |
|---|---|---|
-p, --prompt | string | Required prompt/edit instruction |
-f, --file | path | Output path; auto-named if omitted |
-i, --image | repeatable path | Use edits endpoint; supports multiple references |
-m, --mask | PNG path | Inpaint with alpha mask; requires -i |
--model | gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst | Agent must pass the resolved choice explicitly |
--size | 1k, 2k, 4k, portrait, landscape, square, wide, tall, or literal | Canvas size |
--quality | low, medium, high, auto; 2.5 also xhigh, max | Cost/quality dial; check model-specific limits |
-n, --n | integer | Number of images |
--background | auto, opaque; 2.5 also transparent | Transparency requires PNG or WebP, not JPEG |
--input-fidelity | low, high; omitted by default | Edit-only; explicit 2.5 values are forwarded to the API, not assumed supported |
--moderation | auto, low | Generation moderation setting |
--format | png, jpeg, webp | Output encoding |
--compression | 0-100 | JPEG/WebP compression |
--user | string | Optional end-user identifier |
Quality starting points (not guarantees; keep the user's agreed setting). For 2.5, these take precedence over fixed quality advice in older craft references:
low: cheap drafts and broad exploration; multiple variants require user authorization.medium: normal exploration, style probing, balanced cost.high: CLI default and a candidate for final assets, dense text, diagrams and UI. On 2.5, evaluate against the task requirements; do not assume medium fails or a higher setting always wins.xhigh / max: 2.5-only options for higher-quality work; discuss the cost trade-off before increasing an already agreed quality. Do not use them automatically for budget-conscious requests.Size policy:
1k / 1024x1024portraitlandscape2k4ktall| Mode | Trigger | Endpoint |
|---|---|---|
| Text-to-image | no -i | /v1/images/generations |
| Reference edit | one or more -i | /v1/images/edits |
| Inpaint | -i + -m | /v1/images/edits with mask |
Surface API errors verbatim enough for debugging; exit codes: 0 success, 1 API/refusal, 2 bad args/missing key.
references/gallery.md, then one matching references/gallery-*.md category and its actual prompt text. Read only relevant sections of references/craft.md or the historical references/openai-cookbook.md when needed.references/openai-image-2.5-generation.md (photo/product/illustration), references/openai-image-2.5-layout-and-text.md (text/UI/diagrams/panels), or references/openai-image-2.5-editing.md (references/masks/translation).references/openai-image-2.5.md is an optional index; references/openai-image-2.5-migration.md covers migration/comparison; references/models.md owns current API parameters and validation status.references/templates-gpt-image-2.5.md (community adaptations, not verified outputs). Do not preload them or the old Cookbook for 2.5.Load the smallest useful slice, not both model routes. Add a second task slice only for a genuine hybrid. Historical examples do not override current API notes or the user's model/settings.
--model, endpoint mode, size, quality, output path, and required reference/mask files. Omit --input-fidelity unless explicitly needed; do not assume 2.5 always uses or accepts high.-i paths exist; verify -m exists when used.Preserve Curated vs Author + Source metadata when adapting examples. Add new collected prompts to the Reference Gallery before README promotion.