Skip to content

[Partner Nodes] new OpenAI Image node with DynamicCombo and Autogrow#13838

Merged
Kosinkadink merged 2 commits into
masterfrom
feat/api-nodes/new-openai-image-node
May 11, 2026
Merged

[Partner Nodes] new OpenAI Image node with DynamicCombo and Autogrow#13838
Kosinkadink merged 2 commits into
masterfrom
feat/api-nodes/new-openai-image-node

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

@bigcat88 bigcat88 commented May 11, 2026

API Node PR Checklist

Scope

  • Is API Node Change

Pricing & Billing

  • Need pricing update
  • No pricing update

If Need pricing update:

  • Metronome rate cards updated
  • Auto‑billing tests updated and passing

QA

  • QA done
  • QA not required

Comms

  • Informed Kosinkadink

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request introduces OpenAIGPTImageNodeV2, a new node that consolidates GPT image generation capabilities with dynamic model switching. The node adds shared input definitions for quality, up to 16 reference images, and an optional mask, then uses a dynamic schema to switch between gpt-image-2 (with custom dimensions and restricted background options) and legacy gpt-image-1/1.5 models (with fixed sizes). The execution logic validates mask constraints, enforces custom resolution rules for gpt-image-2, downsamples reference images, and routes requests to either the OpenAI edits endpoint (when a mask is present) or the generations endpoint. The original OpenAIGPTImage1 node is marked as deprecated, and the new node is registered in the extension's node list.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The pull request description is a checklist template that does not provide meaningful details about the changes being made. Provide a descriptive summary of what the PR accomplishes, why it's needed, and any key implementation details or considerations.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: introducing a new OpenAI GPT Image node (V2) with DynamicCombo model selection and Autogrow widget for reference images.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
comfy_api_nodes/nodes_openai.py (1)

878-917: ⚡ Quick win

Move the new image/mask preprocessing off the request coroutine.

This path can now synchronously flatten, downscale, and PNG-encode up to 16 reference images plus a mask inside async def execute, so one large edit request can block other API-node work on the same event loop. Please push that preparation into asyncio.to_thread(...) or an equivalent background helper. Based on learnings: In comfy_api_nodes Python async node implementations, if the PR adds new synchronous CPU/IO work inside async def execute, prefer offloading with asyncio.to_thread (or an equivalent background executor) to avoid blocking the event loop.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@comfy_api_nodes/nodes_openai.py` around lines 878 - 917, The image/mask
flattening, downscaling and PNG encoding in the execute coroutine (code paths
using image_tensors, flat, downscale_image_tensor, mask and building files) must
be moved out of the event loop into a synchronous helper run via
asyncio.to_thread; implement a synchronous function (e.g. prepare_image_files or
preprocess_images_and_mask) that accepts image_tensors and mask, performs the
flattening, downscale_image_tensor calls, converts tensors to uint8 numpy
arrays, creates PNG BytesIO objects and returns the files list, and then in
async def execute call files = await asyncio.to_thread(prepare_image_files,
image_tensors, mask); ensure the helper preserves the same behavior (single
"image" vs "image[]" naming, mask validation and exception raising) and returns
seeked BytesIO objects ready for upload.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@comfy_api_nodes/nodes_openai.py`:
- Around line 768-777: The new "seed" control is declared but never forwarded to
the OpenAI image API, so OpenAIGPTImageNodeV2 ignores it; update the code that
builds the generation and edit request bodies (the places that assemble the
image generation payload and the image edit payload in OpenAIGPTImageNodeV2) to
include the seed value (e.g., add seed: seedValue or the appropriate field name
used by the target API) when present, or if seeding is unsupported by the
backend remove the "seed" IO.Int.Input control; ensure both the generation and
edit request constructors reference the same seed input so the value is not
dropped end-to-end.
- Around line 654-662: The input allows up to 16 images but the code only
validates masks via n_images and doesn't reject larger batched tensors before
calling the edits endpoint; add a preflight validation where the "images" input
is processed (the same place that computes n_images and the codepath that
uploads frames to the edits endpoint) to count the total individual
images/frames in any tensor/batched input and throw/return a clear client-side
error if count > 16, ensuring this check runs before any upload/edits API call;
apply the same check to the alternate upload branch referenced (the code
handling batched/frame uploads used elsewhere around the edits call).

---

Nitpick comments:
In `@comfy_api_nodes/nodes_openai.py`:
- Around line 878-917: The image/mask flattening, downscaling and PNG encoding
in the execute coroutine (code paths using image_tensors, flat,
downscale_image_tensor, mask and building files) must be moved out of the event
loop into a synchronous helper run via asyncio.to_thread; implement a
synchronous function (e.g. prepare_image_files or preprocess_images_and_mask)
that accepts image_tensors and mask, performs the flattening,
downscale_image_tensor calls, converts tensors to uint8 numpy arrays, creates
PNG BytesIO objects and returns the files list, and then in async def execute
call files = await asyncio.to_thread(prepare_image_files, image_tensors, mask);
ensure the helper preserves the same behavior (single "image" vs "image[]"
naming, mask validation and exception raising) and returns seeked BytesIO
objects ready for upload.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 243d920f-4b44-4de3-8697-fad30a2f48bf

📥 Commits

Reviewing files that changed from the base of the PR and between 52976f3 and f35d761.

📒 Files selected for processing (1)
  • comfy_api_nodes/nodes_openai.py

Comment thread comfy_api_nodes/nodes_openai.py
Comment thread comfy_api_nodes/nodes_openai.py
@Kosinkadink Kosinkadink merged commit 428c323 into master May 11, 2026
17 checks passed
@bigcat88 bigcat88 deleted the feat/api-nodes/new-openai-image-node branch May 11, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants