codex-gpt-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodex GPT Image
Codex GPT 图像工具
Use this skill to generate or edit images through Codex OAuth instead of the OpenAI API-key path. The bundled CLI reads the local Codex auth file and calls the Codex Images backend endpoints.
使用本Skill可通过Codex OAuth认证而非OpenAI API密钥路径生成或编辑图片。内置CLI会读取本地Codex认证文件并调用Codex Images后端接口。
When To Use
使用场景
- The user asks to use or GPT Image through Codex auth/subscription.
gpt-image-2 - The current agent supports but does not have a native image tool.
SKILL.md - The user explicitly does not want to use .
OPENAI_API_KEY - The user wants the same local image workflow across Codex, Claude Code, OpenClaw, Hermes Agent, or similar agents.
Do not use this skill when the user wants the official OpenAI Images API, an OpenAI-compatible gateway, or API-key billing. This skill is deliberately Codex-OAuth-only.
- 用户要求通过Codex认证/订阅使用或GPT图像工具时
gpt-image-2 - 当前Agent支持但无原生图像工具时
SKILL.md - 用户明确表示不想使用时
OPENAI_API_KEY - 用户希望在Codex、Claude Code、OpenClaw、Hermes Agent或同类Agent中使用统一的本地图像工作流时
当用户需要官方OpenAI Images API、兼容OpenAI的网关或API密钥计费服务时,请勿使用本Skill。本Skill仅支持Codex OAuth认证。
Core Workflow
核心工作流
All CLI commands below assume the working directory is this skill folder. Otherwise, resolve the absolute path to from this .
scripts/codex_gpt_image.pySKILL.md-
Check local Codex auth:bash
python3 scripts/codex_gpt_image.py auth-status -
If Codex auth is missing, run the device-code login flow:bash
python3 scripts/codex_gpt_image.py login --open-browserThe CLI prints a browser URL and a short user code. The user must complete this step; never ask them to paste tokens. -
Generate an image with the user's actual prompt. Choose only the CLI flags required by the request, and do not reuse prompt wording from this skill.
-
Edit or use reference images by passing one or moreinputs. For edits, build the prompt from the user's requested changes and the invariants that must stay unchanged.
--image -
Report the saved path(s), model, size, and whether Codex OAuth was used.
以下所有CLI命令均假设工作目录为当前Skill文件夹。否则,请从本所在路径解析的绝对路径。
SKILL.mdscripts/codex_gpt_image.py-
检查本地Codex认证状态:bash
python3 scripts/codex_gpt_image.py auth-status -
若缺少Codex认证,请运行设备码登录流程:bash
python3 scripts/codex_gpt_image.py login --open-browserCLI会打印浏览器URL和短用户码。用户必须完成此步骤;切勿要求用户粘贴令牌。 -
使用用户提供的实际提示词生成图片。仅选择请求所需的CLI参数,请勿复用本Skill中的提示词表述。
-
通过传入一个或多个参数来编辑或使用参考图片。编辑时,需结合用户要求的修改内容和必须保留的不变内容构建提示词。
--image -
报告图片保存路径、使用的模型、尺寸以及是否采用了Codex OAuth认证。
Defaults
默认配置
- Auth file:
~/.codex/auth.json - Override auth file:
CODEX_AUTH_FILE=/path/to/auth.json - Login fallback: uses OpenAI Codex device-code auth and writes the same auth file
login - Login client id: ,
--client-id, then the public Codex defaultCODEX_APP_SERVER_LOGIN_CLIENT_ID - Images base URL:
https://chatgpt.com/backend-api/codex - Image model:
gpt-image-2 - Size:
auto - Quality:
auto - Background:
auto - Moderation:
auto - Output format:
png - Output compression: for
100andjpegwebp
For detailed parameter values, defaults, model-specific constraints, and CLI mapping, read .
references/openai-images-api-parameters.md- 认证文件:
~/.codex/auth.json - 自定义认证文件:
CODEX_AUTH_FILE=/path/to/auth.json - 登录备选方案:命令使用OpenAI Codex设备码认证并写入相同的认证文件
login - 登录客户端ID:优先使用参数、
--client-id环境变量,其次为公开的Codex默认值CODEX_APP_SERVER_LOGIN_CLIENT_ID - 图像基础URL:
https://chatgpt.com/backend-api/codex - 图像模型:
gpt-image-2 - 尺寸:
auto - 画质:
auto - 背景:
auto - 内容审核:
auto - 输出格式:
png - 输出压缩率:和
jpeg格式为webp100
如需了解详细参数值、默认配置、模型专属限制及CLI参数映射,请阅读。
references/openai-images-api-parameters.mdParameter Selection
参数选择
Prefer the official API defaults unless the user request requires a specific option. Read the reference before choosing explicit , , , , , or values.
modelsizequalitybackgroundmoderationoutput_format除非用户请求明确要求特定选项,否则优先使用官方API默认值。在选择、、、、或的明确值前,请先查阅参考文档。
modelsizequalitybackgroundmoderationoutput_formatPrompting
提示词撰写
Keep prompts explicit and production-oriented:
- State the intended asset type.
- Quote any exact visible text.
- Specify composition, background, style, and constraints.
- For edits, repeat invariants: what must stay unchanged.
- Avoid adding logos, watermarks, or extra text unless requested.
提示词需清晰明确、符合生产需求:
- 说明目标素材类型
- 引用所有需显示的精确文本
- 指定构图、背景、风格及约束条件
- 编辑时需重复强调必须保留的不变内容
- 除非用户要求,否则请勿添加标识、水印或额外文本
Failure Handling
故障处理
- Missing auth file: run , or ask the user to run
codex_gpt_image.py login --open-browser, then retry.codex login - 401/403: the Codex OAuth token may be expired, the account may not have access, or the endpoint may reject the session. Ask the user to refresh Codex auth.
- Network failures: retry once if the request is idempotent and the user accepts possible duplicate image generation.
- Never print or paste tokens from .
~/.codex/auth.json
- 缺少认证文件:运行,或要求用户运行
codex_gpt_image.py login --open-browser后重试codex login - 401/403错误:Codex OAuth令牌可能已过期、账户无访问权限或接口拒绝会话。请要求用户刷新Codex认证
- 网络故障:若请求具备幂等性且用户接受可能重复生成图片,则重试一次
- 切勿打印或粘贴中的令牌
~/.codex/auth.json
Implementation Notes
实现说明
The CLI sends Codex Images requests with:
- generation endpoint:
POST https://chatgpt.com/backend-api/codex/images/generations - edit endpoint:
POST https://chatgpt.com/backend-api/codex/images/edits - auth:
Authorization: Bearer <access token from ~/.codex/auth.json> - model:
gpt-image-2
It parses the JSON Images response and writes returned base64 image payloads to local files.
CLI发送Codex Images请求的细节:
- 生成接口:
POST https://chatgpt.com/backend-api/codex/images/generations - 编辑接口:
POST https://chatgpt.com/backend-api/codex/images/edits - 认证方式:
Authorization: Bearer <从~/.codex/auth.json获取的访问令牌> - 使用模型:
gpt-image-2
CLI会解析Images接口返回的JSON响应,并将返回的base64图像数据写入本地文件。