Nodes/arkennemasis Nodes/arkennemasis Replicate Image Gen (GPT-Image-2)
ComfyUI Node

arkennemasis Replicate Image Gen (GPT-Image-2)

Generate, edit, and don't blow the rate limit

By Hishamahmer·Created 2 months ago·Updated 8 days ago· 9
arkennemasis Replicate Image Gen (GPT-Image-2)
  • image_1
  • image_2
  • image_3
  • image_4
  • settings
  • image
prompt
number_of_images1
aspect_ratio
quality
background
output_format
moderation
api_token
timeout_seconds0
force_rerunfalse
run_mode
max_concurrent2

GPT-Image-2 is a closed model - there are no weights to download, so the only way to get it into a ComfyUI graph is through an API node like this one. It generates images from a prompt and edits images you feed in (up to four of them), which makes it one of the pack's two image workhorses: the edit path is how you keep a consistent product or character, since the model looks at your reference while it works instead of re-inventing it. The cost is per call, so the two things that matter are the key and the rate limit.

How it works

Required: just prompt. Optional image inputs image_1 through image_4 switch it into edit/reference mode; omit them and it's text-to-image. One output: image, straight into a Save Image node.

The generation controls mirror the model's own API: number_of_images (1–10), aspect_ratio (a long enum - 1:1, 3:2, 16:9, specific pixel sizes, etc.), quality (low/medium/high/auto), background (auto/transparent/opaque - transparent is the product-photo mode), output_format (png/jpeg/webp), and moderation (auto/low). Everything left on default isn't sent, so the model's defaults apply - the pack's way of keeping the payload clean.

Then the two inputs that save your account:

  • run_mode - one at a time (default) serialises every arkennemasis API node in the graph. This exists because ComfyUI runs async nodes concurrently, and Replicate throttles to "6 requests per minute with a burst of 1" while an account holds under $5 credit - parallel calls reliably return 429. all at once is faster when your rate limit allows it, bounded by max_concurrent (default 2).
  • timeout_seconds (0 = wait indefinitely), force_rerun, and api_token (blank falls back to REPLICATE_API_TOKEN env or a .env file).

settings is the pack's neat trick: wire one shared Image Gen Settings node into many Image Gen nodes at once, so a single aspect_ratio/quality drives 24 generators (a STRING can't be wired into a COMBO widget in ComfyUI, hence the typed ARK_IMAGE_SETTINGS socket). number_of_images is deliberately not shared - multiplying it across every wired node is rarely what you want.

Two gotchas that will actually hit you

429s are a shape of the pack, not a bug. If your account is under $5 credit and you run a 24-image batch on all at once, you'll see them. The retry layer backs off exponentially on 429s and never retries a moderation refusal, but the fix is the one at a time default - leave it until your rate limit actually allows concurrency. And watch the batch-filename trap: in a graph that names files deterministically, a number_of_images above 1 lands all the extras on the same filename and they overwrite each other. Set it per node.

Install

ReplicateOpenAIGPTImage2 is one of the 61 nodes in the comfyui-arkennemasis pack, in arkennemasis/Image Gen:

cd ComfyUI/custom_nodes
git clone https://github.com/Hishamahmer/comfyui-arkennemasis
pip install -r comfyui-arkennemasis/requirements.txt   # then restart ComfyUI

Get a token at https://replicate.com/account/api-tokens and paste it into api_token, set REPLICATE_API_TOKEN, or add it to a .env in ComfyUI's root. Or ComfyUI Manager → Install via Git URL with the repo URL.

And the honest alternative: the same gpt-image-2 model is reachable through the pack's Codex Image Gen node using a paid ChatGPT subscription - no API key, billed to your plan instead of per image. If you already pay for ChatGPT, that's the cheaper door to the same model.

Categoryarkennemasis/Image Gen

Inputs (17)

NameTypeDefaultDescription
promptSTRING
image_1optIMAGEOptional image to edit/transform. Omit for text-to-image. Can be a batch.
image_2optIMAGE
image_3optIMAGE
image_4optIMAGE
number_of_imagesoptINT11–10
aspect_ratiooptCOMBO19 options: default, 1:1, 3:2, 2:3, 4:3, 3:4, +13
qualityoptCOMBO5 options: default, low, medium, high, auto
backgroundoptCOMBO4 options: default, auto, transparent, opaque
output_formatoptCOMBO4 options: default, png, jpeg, webp
moderationoptCOMBO3 options: default, auto, low
api_tokenoptSTRINGReplicate API token (optional). Blank = use REPLICATE_API_TOKEN from the environment or a .env file.
timeout_secondsoptINT00–86400Max seconds to wait for the model. 0 = wait indefinitely.
force_rerunoptBOOLEANfalseRe-call the API even if inputs are unchanged.
run_modeoptCOMBOComfyUI runs async nodes concurrently. 'one at a time' serialises every arkennemasis API node in the graph — use it when the provider throttles bursts (Replicate allows a burst of 1 under $5 credit). 'all at once' is faster when your rate limit allows it.
max_concurrentoptINT20–32Only used when run_mode is 'all at once': how many arkennemasis API calls may be in flight together. 0 = no cap. 2 is a safe default for a 24-shot batch.
settingsoptARK_IMAGE_SETTINGSOptional: wire one 'Image Gen Settings (shared)' node in here to drive this and every other Image Gen node from a single place. Any field it leaves on "use node's own" falls back to the widgets above.

Outputs (1)

NameTypeDescription
imageIMAGE