Skip to content

[Partner Nodes] allow custom resolutions for GPTImage2 node#13631

Merged
Kosinkadink merged 1 commit intomasterfrom
feat/api-nodes/GPTImage2-custom-res
Apr 30, 2026
Merged

[Partner Nodes] allow custom resolutions for GPTImage2 node#13631
Kosinkadink merged 1 commit intomasterfrom
feat/api-nodes/GPTImage2-custom-res

Conversation

@bigcat88
Copy link
Copy Markdown
Contributor

@bigcat88 bigcat88 commented Apr 30, 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

@bigcat88 bigcat88 changed the title feat(api-nodes): allow custom resolutions for GPTImage2 node [Partner Nodes] allow custom resolutions for GPTImage2 node Apr 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

📝 Walkthrough

Walkthrough

Adds a "Custom" size option to the OpenAI GPT Image node and new custom_width and custom_height inputs. Updates OpenAIGPTImage1.execute(...) signature to accept those parameters and adds a size == "Custom" branch that enforces GPT Image 2-only usage, width/height multiples of 16, max edge ≤ 3840, aspect ratio ≤ 3:1, and total-pixel bounds; on success it formats size as "{custom_width}x{custom_height}". Also updates GPT Image 2 pricing badge range upper bounds for all quality tiers.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title '[Partner Nodes] allow custom resolutions for GPTImage2 node' directly and clearly summarizes the main change—adding custom resolution support to the GPTImage2 node.
Description check ✅ Passed The description includes a completed API Node PR Checklist that is directly relevant to the changeset, confirming scope, pricing decisions, and communication, making it related to the PR's objectives.
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
Review rate limit: 6/8 reviews remaining, refill in 11 minutes and 2 seconds.

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

Signed-off-by: bigcat88 <bigcat88@icloud.com>
@bigcat88 bigcat88 force-pushed the feat/api-nodes/GPTImage2-custom-res branch from 148c175 to 3901489 Compare April 30, 2026 07:58
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@comfy_api_nodes/nodes_openai.py`:
- Around line 539-544: The validation for custom image dimensions can raise
ZeroDivisionError when custom_width or custom_height is 0; before performing
modulus or computing ratio, add an explicit positivity check for custom_width
and custom_height (e.g., if custom_width <= 0 or custom_height <= 0: raise
ValueError("Custom width and height must be positive integers, got
{custom_width}x{custom_height}")), then proceed with the existing checks that
use custom_width % 16, custom_height % 16 and compute ratio; update the
validation block around the custom_width/custom_height/ratio logic in
nodes_openai.py accordingly.
🪄 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: 974007cd-8df2-49f1-b858-bcd500cc5b72

📥 Commits

Reviewing files that changed from the base of the PR and between 148c175 and 3901489.

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

Comment on lines +539 to +544
if custom_width % 16 != 0 or custom_height % 16 != 0:
raise ValueError(f"Custom width and height must be multiples of 16, got {custom_width}x{custom_height}")
if max(custom_width, custom_height) > 3840:
raise ValueError(f"Custom resolution max edge must be <= 3840, got {custom_width}x{custom_height}")
ratio = max(custom_width, custom_height) / min(custom_width, custom_height)
if ratio > 3:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard non-positive custom dimensions before aspect-ratio division

The custom-size validation can throw an unhandled ZeroDivisionError on Line 543 when either dimension is 0. Add an explicit positivity check so invalid input consistently returns ValueError.

Suggested fix
         if size == "Custom":
             if model != "gpt-image-2":
                 raise ValueError("Custom resolution is only supported by GPT Image 2 model")
+            if custom_width <= 0 or custom_height <= 0:
+                raise ValueError(
+                    f"Custom width and height must be positive integers, got {custom_width}x{custom_height}"
+                )
             if custom_width % 16 != 0 or custom_height % 16 != 0:
                 raise ValueError(f"Custom width and height must be multiples of 16, got {custom_width}x{custom_height}")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@comfy_api_nodes/nodes_openai.py` around lines 539 - 544, The validation for
custom image dimensions can raise ZeroDivisionError when custom_width or
custom_height is 0; before performing modulus or computing ratio, add an
explicit positivity check for custom_width and custom_height (e.g., if
custom_width <= 0 or custom_height <= 0: raise ValueError("Custom width and
height must be positive integers, got {custom_width}x{custom_height}")), then
proceed with the existing checks that use custom_width % 16, custom_height % 16
and compute ratio; update the validation block around the
custom_width/custom_height/ratio logic in nodes_openai.py accordingly.

@Kosinkadink
Copy link
Copy Markdown
Member

In the long term, using DynamicCombo would allow for the custom width/height to appear only when custom is selected, but that can be done with node replacement when we feel like it.

@Kosinkadink Kosinkadink merged commit 38ecad8 into master Apr 30, 2026
17 checks passed
@bigcat88 bigcat88 deleted the feat/api-nodes/GPTImage2-custom-res branch April 30, 2026 08:10
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