Nodes/Codex ImageGen/Codex Exec ImageGen
ComfyUI Node

Codex Exec ImageGen

GPT Image inside ComfyUI — no API key, just the Codex CLI

By DocWorkBox·Created 5 months ago·Updated 5 months ago· 21
Codex Exec ImageGen
  • 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
concurrency_count1
prompt
prompt_2
prompt_3
prompt_4
prompt_5
prompt_6
prompt_7
prompt_8
aspect_rationone
modelgpt-5.4
reasoning_effortmedium
working_directory
json_outputtrue
auto_save_to_outputfalse
output_last_message_path
skip_git_repo_checktrue
ephemeraltrue

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 reveals prompt_2..8 and images_2..8 and launches that many independent codex exec jobs in parallel. This is the one genuinely clever knob; it turns the node into a batch generator.
  • images - an IMAGE port for reference/edit input. The node saves the tensor into ComfyUI's input dir and passes it via --image.
  • aspect_ratio - eight options from none to 16: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) and reasoning_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_HOME doesn't reuse your system ~/.codex session, 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. Check where codex (Windows) or which codex; if it exists but ComfyUI can't find it, set CODEX_CLI_PATH before 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.txt and stdout.jsonl; if you find $imagegen usage help, Codex ran but generation never fired.
  • 只读沙箱 network-blocked errors mean $imagegen couldn't reach the image API - check proxies/VPN on the ComfyUI process, not just your browser.
  • Caching. The node is NOT_IDEMPOTENT with 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.

CategoryCodex/ImageGen

Inputs (26)

NameTypeDefaultDescription
concurrency_countCOMBO18 options: 1, 2, 3, 4, 5, 6, +2
promptSTRING
imagesoptIMAGE
prompt_2optSTRING
prompt_3optSTRING
prompt_4optSTRING
prompt_5optSTRING
prompt_6optSTRING
prompt_7optSTRING
prompt_8optSTRING
images_2optIMAGE
images_3optIMAGE
images_4optIMAGE
images_5optIMAGE
images_6optIMAGE
images_7optIMAGE
images_8optIMAGE
aspect_ratiooptCOMBOnone8 options: none, 1:1, 16:9, 9:16, 4:3, 3:4, +2
modeloptCOMBOgpt-5.42 options: gpt-5.4, gpt-5.5
reasoning_effortoptCOMBOmedium3 options: low, medium, high
working_directoryoptSTRING
json_outputoptBOOLEANtrue
auto_save_to_outputoptBOOLEANfalse
output_last_message_pathoptSTRING
skip_git_repo_checkoptBOOLEANtrue
ephemeraloptBOOLEANtrue

Outputs (7)

NameTypeDescription
generated_imageIMAGE
generated_image_pathSTRING
last_messageSTRING
raw_jsonlSTRING
used_promptSTRING
exit_codeINT
successBOOLEAN