gpt-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegpt-image
gpt-image
Agent runbook for GPT Image 2 generation/editing. Use the prompt library + packaged CLI. Do not reimplement image API code.
GPT Image 2生成/编辑的Agent运行手册。使用提示词库+打包好的CLI工具。请勿重新实现图像API代码。
Operating loop
操作流程
- Classify request: ,
generate,edit, orinpaint; identify asset type, exact text, aspect ratio, references, safety constraints, and budget/quality.multi-reference - Search references first: open ; load/search the closest
references/gallery.mdfile(s). Read actualreferences/gallery-<category>.mdtext before choosing a pattern.**Prompt** - Refine with craft: load for dense text, diagrams, UI, data visualization, multi-panel layouts, weak prompts, or no close gallery match.
references/craft.md - Confer when useful: before costly/ambiguous/high-polish calls, present 1–3 matched directions plus planned size/quality; ask at most one concise question. Skip long discussion for precise “generate now” requests.
- Preflight, no side effects: use existing CLI/skill if present. Check command availability (), 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.
command -v gpt-image - No blind setup: do not reinstall, overwrite skill folders, create/modify , or write API keys unless the user explicitly requested setup. Global/shared installs are opt-in only.
.env - Execute via CLI only: call or
gpt-image. Do not create a newscripts/generate.py, SDK wrapper, or ad-hoc script for normal image requests.generate.py - Report: output file path(s), key flags, and one concise refinement suggestion if useful.
Fast path: precise prompt + explicit “generate now” → quick reference/craft check, then CLI.
- 请求分类:判断请求类型为(生成)、
generate(编辑)、edit(修复)或inpaint(多参考);确定资产类型、精确文本、宽高比、参考素材、安全约束以及预算/质量要求。multi-reference - 优先搜索参考素材:打开;加载并搜索最匹配的
references/gallery.md文件。选择模式前请查看实际的references/gallery-<category>.md文本内容。**Prompt** - 结合技巧优化:若涉及密集文本、图表、UI、数据可视化、多面板布局、弱提示词或无匹配图库内容,加载文件。
references/craft.md - 必要时确认方向:在执行高成本/模糊/高精度生成请求前,提供1-3个匹配方向以及计划的尺寸/质量参数;最多提出一个简洁问题。对于明确要求“立即生成”的精准请求,跳过冗长讨论。
- 预检查,无副作用:优先使用现有CLI/技能。检查命令可用性(),若存在工具管理器则查看已安装工具列表,或使用运行时自带的技能注册表。在云/托管运行时中请勿假设本地主目录路径。
command -v gpt-image - 禁止盲目配置:除非用户明确要求配置,否则请勿重新安装、覆盖技能文件夹、创建/修改文件或写入API密钥。全局/共享安装需用户主动选择。
.env - 仅通过CLI执行:调用或
gpt-image。对于常规图像请求,请勿创建新的scripts/generate.py文件、SDK包装器或临时脚本。generate.py - 结果报告:输出文件路径、关键参数,必要时提供一条简洁的优化建议。
快速路径:精准提示词+明确“立即生成”指令 → 快速检查参考素材/技巧文件,然后调用CLI。
CLI resolution
CLI调用优先级
Preferred call order:
bash
undefined推荐调用顺序:
bash
undefinedExisting CLI on PATH
PATH中的现有CLI
gpt-image -p "PROMPT" [-f OUT] [-i REF...] [-m MASK] [options]
gpt-image -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" -p "PROMPT" [-f OUT] [-i REF...] [-m MASK] [options]
uv run "$SKILL_DIR/scripts/generate.py" -p "PROMPT" [-f OUT] [-i REF...] [-m MASK] [options]
Direct transient CLI when the user requested setup/one-off CLI execution
用户要求配置/一次性CLI执行时,直接使用临时CLI
uvx --from git+https://github.com/wuyoscar/gpt_image_2_skill gpt-image -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.uvx --from git+https://github.com/wuyoscar/gpt_image_2_skill gpt-image -p "PROMPT" [options]
`scripts/generate.py`是启动器:优先使用仓库本地的`src/gpt_image_cli` → 已安装的`gpt-image` → PATH中的`gpt-image` → 临时`uvx`/`uv`作为备选。Key and cost rules
密钥与成本规则
- CLI reads from process env, then
OPENAI_API_KEY, then.envwithout overriding existing env; successful API calls may bill the user’s OpenAI account.~/.env - If host/runtime has native platform-managed image generation and the user wants that path, use the host tool instead of this CLI.
- If is unset, report missing key or use host-native generation when requested; do not write secrets.
OPENAI_API_KEY - If user wants to avoid local-key use, respect ; if a key exists in
unset OPENAI_API_KEY/.env, tell them to remove/rename it for the session rather than working around it.~/.env - Never print secret values.
- CLI会从进程环境变量读取,其次是
OPENAI_API_KEY文件,最后是.env文件,但不会覆盖现有环境变量;成功的API调用可能会从用户的OpenAI账户扣费。~/.env - 若宿主/运行时具备原生平台托管的图像生成功能且用户希望使用该方式,则优先使用宿主工具而非本CLI。
- 若未设置,报告密钥缺失,或在用户要求时使用宿主原生生成功能;请勿写入密钥信息。
OPENAI_API_KEY - 若用户希望避免使用本地密钥,需遵守的要求;若
unset OPENAI_API_KEY/.env中存在密钥,请告知用户在本次会话中移除/重命名该文件,而非绕过此限制。~/.env - 绝对禁止打印密钥等敏感信息。
Flags
参数选项
| Flag | Values | Use |
|---|---|---|
| string | Required prompt/edit instruction |
| path | Output path; auto-named if omitted |
| repeatable path | Use edits endpoint; supports multiple references |
| PNG path | Inpaint with alpha mask; requires |
| default | Image model |
| | Canvas size |
| | Cost/quality dial |
| integer | Number of images |
| | Generation background |
| | Generation moderation setting |
| | Output encoding |
| | JPEG/WebP compression |
| string | Optional end-user identifier |
Quality policy:
- : cheap drafts, broad exploration, many variants.
low - : normal exploration, style probing, balanced cost.
medium - : final assets, Chinese text, posters, diagrams, UI, paper figures, dense labels.
high
Size policy:
- default/social square: /
1k1024x1024 - poster/mobile/beauty:
portrait - landscape/gameplay/photo:
landscape - print/paper figure:
2k - widescreen hero:
4k - vertical story/banner:
tall
| 参数 | 取值 | 用途 |
|---|---|---|
| string | 必填的提示词/编辑指令 |
| path | 输出路径;省略时自动命名 |
| 可重复传入路径 | 使用编辑端点;支持多个参考图像 |
| PNG路径 | 使用Alpha蒙版进行图像修复;需配合 |
| 默认值 | 图像生成模型 |
| | 画布尺寸 |
| | 成本/质量调节 |
| integer | 生成图像数量 |
| | 生成背景设置 |
| | 生成内容审核设置 |
| | 输出编码格式 |
| | JPEG/WebP压缩率 |
| string | 可选的终端用户标识符 |
质量策略:
- :低成本草稿、广泛探索、多版本变体。
low - :常规探索、风格测试、成本与质量平衡。
medium - :最终资产、中文文本、海报、图表、UI、论文插图、密集标签。
high
尺寸策略:
- 默认/社交平台正方形:/
1k1024x1024 - 海报/移动端/人像:(竖版)
portrait - 风景/游戏画面/照片:(横版)
landscape - 印刷/手办模型:
2k - 宽屏横幅:
4k - 竖版故事/广告条:(长竖版)
tall
Endpoint routing
端点路由
| Mode | Trigger | Endpoint |
|---|---|---|
| Text-to-image | no | |
| Reference edit | one or more | |
| Inpaint | | |
Surface API errors verbatim enough for debugging; exit codes: success, API/refusal, bad args/missing key.
012| 模式 | 触发条件 | 端点 |
|---|---|---|
| 文本转图像 | 未传入 | |
| 参考图像编辑 | 传入一个或多个 | |
| 图像修复 | 同时传入 | 带蒙版的 |
需完整呈现API错误信息以便调试;退出码:表示成功,表示API拒绝,表示参数错误/密钥缺失。
012Reference loading
参考文件加载
- : routing index for the 162-prompt Reference Gallery Atlas. Load first.
references/gallery.md - : concrete prompts, previews, paths, metadata, attribution. Load 1 category for normal requests; 2–3 for hybrids.
references/gallery-*.md - : prompt-craft checklist. Load for prompt repair, exact text, UI/data/diagram grammar, edit invariants, and multi-panel consistency.
references/craft.md - : official parameter/model semantics. Load for API behavior or model capability questions.
references/openai-cookbook.md
Reference loading policy: load the smallest useful slice; never load all category files by default.
- :包含162个提示词的参考图库索引,优先加载。
references/gallery.md - :具体提示词、预览图、路径、元数据、来源信息。常规请求加载1个分类;混合场景加载2-3个分类。
references/gallery-*.md - :提示词优化清单。用于提示词修复、精确文本、UI/数据/图表语法、编辑规则、多面板一致性调整。
references/craft.md - :官方参数/模型语义说明。用于查询API行为或模型能力相关问题。
references/openai-cookbook.md
参考文件加载规则:加载最小必要的内容片段;默认情况下请勿加载所有分类文件。
Verification
验证步骤
- Before API call: confirm endpoint mode, size, quality, output path, and required reference/mask files.
- After CLI call: report path(s) printed by the CLI and surface stderr on failure.
- For edits/inpaints: verify paths exist; verify
-iexists when used.-m
Preserve vs metadata when adapting examples. Add new collected prompts to the Reference Gallery before README promotion.
CuratedAuthor + Source- API调用前:确认端点模式、尺寸、质量、输出路径以及所需的参考/蒙版文件是否存在。
- CLI调用后:报告CLI输出的文件路径,若调用失败则显示stderr内容。
- 编辑/修复场景:验证对应的路径是否存在;使用
-i时需验证蒙版文件是否存在。-m
调整示例时请保留(精选)与(作者+来源)元数据。将新收集的提示词添加到参考图库后,再更新README文档。
CuratedAuthor + Source