Codex Exec ImageGen
GPT Image inside ComfyUI — no API key, just the Codex CLI
- images
- images_2
- images_3
- images_4
- images_5
- images_6
- images_7
- images_8
- generated_image
- generated_image_path
- last_message
- raw_jsonl
- used_prompt
- exit_code
- success
The name is a lie, in the best possible way. Codex Exec ImageGen doesn't call any OpenAI API with a key you paste in, and it has zero diffusion knobs. What it actually does is run the official Codex CLI in the background - codex exec - with your prompt wrapped in its built-in $imagegen command, then hands the result back to the graph as an IMAGE. The model underneath is GPT Image, which has no open weights; this is the "external API node" pattern, just with the CLI handling auth instead of a config.ini full of secrets. If you already pay for Codex, this is the lowest-friction way to get GPT Image next to your local upscaler. If you don't, keep in mind it's a per-call cloud meter - the free lunch stops at your electricity bill.
What it deliberately refuses to be
Read the author's README once and the philosophy is loud: this node "only exposes the official capabilities" of Codex, and it will not add seed, steps, cfg, sampler, scheduler, checkpoint, VAE, ControlNet, LoRA, latent, or image_count fields. That's a feature, not a limitation. You are renting OpenAI's image model through your Codex login; there's nothing to tune at the diffusion level because the diffusion isn't yours. Want fine-grained control over a render? Wrong node. Want GPT Image quality inside a ComfyUI workflow without touching the API? Exactly the right one.
How it works
Under the hood it builds a command roughly like this:
codex exec --json --sandbox danger-full-access --skip-git-repo-check \
--ephemeral -m gpt-5.4 -c model_reasoning_effort=medium \
-o last_message.txt '$imagegen a red fox in a snowstorm'
Your prompt becomes $imagegen <prompt> - the single-line form that works straight in the Codex CLI. The sandbox is fixed to danger-full-access (not exposed in the UI) because image generation needs network access and file writes. It also runs in an isolated CODEX_HOME under runtime/codex_home/, so it won't load the Codex skills and plugins from your user directory. The progress bar is a stage estimate derived from Codex's JSONL events, not the image model's real percentage, so treat "70%" as "roughly here in the pipeline," not truth.
The inputs that matter
prompt- required, multiline. Everything else is optional.concurrency_count- 1 to 8, default 1. Crank it and the node revealsprompt_2..8andimages_2..8and launches that many independentcodex execjobs in parallel. This is the one genuinely clever knob; it turns the node into a batch generator.images- anIMAGEport for reference/edit input. The node saves the tensor into ComfyUI'sinputdir and passes it via--image.aspect_ratio- eight options fromnoneto16:9. Slight trap: it's not a CLI flag. The author just prepends画面比例 <ratio>to your prompt text. If GPT Image ignores it, that's why.model(gpt-5.4/gpt-5.5) andreasoning_effort(low/medium/high) map straight onto Codex flags.
Outputs
generated_image is an IMAGE list - wire it into a normal Save Image node. Leave auto_save_to_output off (default off for a reason): turn it on and the node saves a copy and your Save Image node saves another, giving you duplicates. The rest - generated_image_path, last_message, raw_jsonl, used_prompt, exit_code, success - are diagnostics for when a run goes sideways, especially used_prompt (what was really sent, $imagegen included) and last_message.
Installing it
ComfyUI Manager, search Codex ImageGen (or the node id codex-imagegen), install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/DocWorkBox/ComfyUI-Codex-ImageGen.git
Then restart ComfyUI. The pack itself has zero pip dependencies and zero model downloads - no checkpoint, no VAE. The real dependency is Codex CLI, which has to be on the PATH ComfyUI sees, and logged in:
npm install -g @openai/codex # or: brew install --cask codex
codex login
Where people get burned
- First run opens a browser login. Expected. The isolated
CODEX_HOMEdoesn't reuse your system~/.codexsession, so authorize once and it sticks. Codex CLI is not installed or not in PATH- the classic. ComfyUI's PATH isn't your terminal's PATH. Checkwhere codex(Windows) orwhich codex; if it exists but ComfyUI can't find it, setCODEX_CLI_PATHbefore launching ComfyUI, e.g.$env:CODEX_CLI_PATH="C:\Users\<you>\AppData\Roaming\npm\codex.cmd".- Runs but no image. Check
runtime/<timestamp>_<uuid>/last_message.txtandstdout.jsonl; if you find$imagegenusage help, Codex ran but generation never fired. 只读沙箱network-blocked errors mean$imagegencouldn't reach the image API - check proxies/VPN on the ComfyUI process, not just your browser.- Caching. The node is
NOT_IDEMPOTENTwith caching disabled, so it re-runs every time. After editing plugin code you must restart ComfyUI or you'll run stale code.
Failures now raise a proper error instead of the old 1×1 placeholder, so trust the error message, then read the task dir's stdout.jsonl and last_message.txt - that's where the real story lives.
Inputs (26)
| Name | Type | Default | Description |
|---|---|---|---|
| concurrency_count | COMBO | 1 | 8 options: 1, 2, 3, 4, 5, 6, +2 |
| prompt | STRING | — | |
| imagesopt | IMAGE | — | |
| prompt_2opt | STRING | — | |
| prompt_3opt | STRING | — | |
| prompt_4opt | STRING | — | |
| prompt_5opt | STRING | — | |
| prompt_6opt | STRING | — | |
| prompt_7opt | STRING | — | |
| prompt_8opt | STRING | — | |
| images_2opt | IMAGE | — | |
| images_3opt | IMAGE | — | |
| images_4opt | IMAGE | — | |
| images_5opt | IMAGE | — | |
| images_6opt | IMAGE | — | |
| images_7opt | IMAGE | — | |
| images_8opt | IMAGE | — | |
| aspect_ratioopt | COMBO | none | 8 options: none, 1:1, 16:9, 9:16, 4:3, 3:4, +2 |
| modelopt | COMBO | gpt-5.4 | 2 options: gpt-5.4, gpt-5.5 |
| reasoning_effortopt | COMBO | medium | 3 options: low, medium, high |
| working_directoryopt | STRING | — | |
| json_outputopt | BOOLEAN | true | — |
| auto_save_to_outputopt | BOOLEAN | false | — |
| output_last_message_pathopt | STRING | — | |
| skip_git_repo_checkopt | BOOLEAN | true | — |
| ephemeralopt | BOOLEAN | true | — |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| generated_image | IMAGE | — |
| generated_image_path | STRING | — |
| last_message | STRING | — |
| raw_jsonl | STRING | — |
| used_prompt | STRING | — |
| exit_code | INT | — |
| success | BOOLEAN | — |