Codex Image Gen logo

Codex Image Gen

Community
zjp1997720
codex-image-gen

给任何已登录 Codex CLI 的 Agent 提供本地生图能力,零私有依赖。只要用户提到生图、画图、生成图片、image generation、文生图、配图、插图、封面、海报、根据 prompt 出图,或要把本机 `~/.codex/auth.json` 里的 Codex OAuth 登录态复用成可执行脚本,都应优先使用本 skill。适用于 Claude Code、Codex、OpenCode 等任何能运行 bash / python3 脚本的 Agent。

Overview

Publisherzjp1997720
Repositoryzhijian-skills
Skill namecodex-image-gen
Stars
780
Forks
99
Bundled files
5
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 5 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by zjp1997720 on GitHub. Read the source before you install it.

Installation

Install the Codex Image Gen AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/zjp1997720/zhijian-skills/tree/main/skills/codex-image-gen
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zjp1997720/zhijian-skills.git /tmp/zhijian-skills
mkdir -p .claude/skills
cp -r /tmp/zhijian-skills/skills/codex-image-gen .claude/skills/codex-image-gen
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Codex Image Gen in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Codex Image Gen on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Codex Image Gen is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Codex Image Gen

目标:把“本机已登录的 Codex OAuth 生图能力”封装成一个零私有依赖的跨 Agent Skill。

它不依赖任何私有模块;任何能执行 python3 的 Agent,只要宿主机已经装好 Codex CLI 并执行过 codex auth login,就能直接调用 scripts/codex_image.py 生图或做图像编辑。

前置条件

必须同时满足:

  1. 本机已安装 Codex CLI
  2. 已执行过 codex auth login
  3. ~/.codex/auth.json 存在且可读
  4. 机器可访问:
    • https://chatgpt.com/backend-api/codex/responses
    • https://auth.openai.com/oauth/token

如果 ~/.codex/auth.json 不存在,不要猜测或绕过。直接提示用户先运行:

bash
codex auth login

这个 skill 能做什么

  • 文生图
  • 配图 / 插图 / 封面图生成
  • image-to-image / 编辑
  • 把本地参考图编码成 data:image/...;base64,... 后发给 Codex Responses API
  • 自动检查 access token 是否过期
  • access token 过期时自动用 refresh token 刷新,并写回 ~/.codex/auth.json
  • 从 SSE 流里提取图片 base64,保存为本地 PNG

核心脚本

相对路径:scripts/codex_image.py

典型调用方式:

bash
python3 scripts/codex_image.py --prompt "极简科技感课程封面,无文字" --aspect landscape

如果 Agent 不是在 skill 根目录执行,就显式传 skill 相对路径或绝对路径,例如:

bash
python3 .claude/skills/codex-image-gen/scripts/codex_image.py \
  --prompt "商业文章封面插图,克制,干净,无文字" \
  --aspect landscape \
  --quality high \
  --out-dir ./outputs

CLI 参数

必填

二选一:

  • --prompt "..."
  • --prompt-file /path/to/prompt.txt

可选

  • --quality low|medium|high:默认 medium
  • --aspect landscape|square|portrait:默认 square
  • --out-dir /path/to/output-dir:默认当前目录
  • --image /path/to/image.png:主编辑图 / 输入图
  • --reference-image /path/to/ref.png:参考图,可重复传入
  • --model gpt-image-2:默认 gpt-image-2

推荐工作方式

1) 最短路径:文生图

bash
python3 scripts/codex_image.py \
  --prompt "蓝白配色的 AI 课程封面插图,几何感,极简,无文字" \
  --aspect landscape \
  --quality high \
  --out-dir ./outputs

2) 用 prompt 文件

bash
python3 scripts/codex_image.py \
  --prompt-file ./prompt.txt \
  --aspect portrait \
  --out-dir ./outputs

3) image-to-image / 编辑

bash
python3 scripts/codex_image.py \
  --prompt "把这张草图做成干净的白板商业插图风格" \
  --image ./draft.png \
  --reference-image ./style-ref.png \
  --aspect landscape \
  --out-dir ./outputs

Agent 执行规则

  1. 先确认 ~/.codex/auth.json 存在;不存在就停止并提示 codex auth login
  2. 优先直接跑 python3 scripts/codex_image.py --help 自检 CLI
  3. 真正执行时,给出明确 prompt,不要只传关键词
  4. 如果用户要封面/配图,默认优先:
    • --aspect landscape
    • --quality high
  5. 如果用户要头像、图标、方图,默认优先:
    • --aspect square
  6. 如果返回 401,直接提示重新登录 Codex
  7. 如果返回 403,优先怀疑 Cloudflare / 请求头不完整 / 登录态异常,不要误判成 prompt 问题

成功输出约定

脚本成功时会输出 JSON:

json
{"success": true, "image": "/absolute/path/to/file.png"}

Agent 应返回:

  • 最终图片路径
  • 使用的 prompt(必要时可简述)
  • 是否用了输入图 / 参考图

失败处理

auth.json 不存在

明确提示:

bash
codex auth login

401 Unauthorized

说明本地登录态失效,建议重新登录:

bash
codex auth login

403 Forbidden

说明大概率是 Cloudflare / 关键请求头 / 账号态问题。先检查:

  • User-Agent: codex_cli_rs/0.0.0
  • originator: codex_cli_rs
  • ChatGPT-Account-ID

没拿到图片数据

说明上游 SSE 响应格式变了,或只返回了中间事件但没有可用图片字段。此时应检查 references/api-notes.md 并根据新响应结构更新脚本。

参考文档

  • API 细节:references/api-notes.md
  • 核心脚本:scripts/codex_image.py

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Codex Image Gen AI skill do?

给任何已登录 Codex CLI 的 Agent 提供本地生图能力,零私有依赖。只要用户提到生图、画图、生成图片、image generation、文生图、配图、插图、封面、海报、根据 prompt 出图,或要把本机 `~/.codex/auth.json` 里的 Codex OAuth 登录态复用成可执行脚本,都应优先使用本 skill。适用于 Claude Code、Codex、OpenCode 等任何能运行 bash / python3 脚本的 Agent。

Why use Codex Image Gen on TypingMind?

Because you install it once and use it with any model. Codex Image Gen is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Codex Image Gen in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/zjp1997720/zhijian-skills/tree/main/skills/codex-image-gen. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Codex Image Gen?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Codex Image Gen?

As many as you like. As long as a model supports skills, you can use Codex Image Gen with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Codex Image Gen AI skill free?

Yes. It is published on GitHub by zjp1997720 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇