Skip to content

feat(image-generator): add gpt-image-2 model support#4436

Closed
waleedlatif1 wants to merge 48 commits intostagingfrom
waleedlatif1/gpt-image-2
Closed

feat(image-generator): add gpt-image-2 model support#4436
waleedlatif1 wants to merge 48 commits intostagingfrom
waleedlatif1/gpt-image-2

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Add gpt-image-2 as a model option in the Image Generator block
  • Wire up gpt-image-2 specific params: size (auto, 1024², 1536×1024, 1024×1536, 2048², 3840×2160), quality (auto/low/medium/high), background (auto/opaque — transparent not supported per docs), output_format (png/jpeg/webp), moderation (auto/low)
  • Share quality/background/output_format wiring with gpt-image-1; moderation is gpt-image-2 only
  • Verified parameter values against OpenAI's official gpt-image-2 docs

Type of Change

  • New feature

Testing

Tested manually. Type check passes.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

waleedlatif1 and others added 30 commits April 3, 2026 23:30
…ership workflow edits via sockets, ui improvements
…ration, signup method feature flags, SSO improvements
* feat(posthog): Add tracking on mothership abort (#4023)

Co-authored-by: Theodore Li <theo@sim.ai>

* fix(login): fix captcha headers for manual login  (#4025)

* fix(signup): fix turnstile key loading

* fix(login): fix captcha header passing

* Catch user already exists, remove login form captcha
…nts, secrets performance, polling refactors, drag resources in mothership
…endar triggers, docs updates, integrations/models pages improvements
…mat, logs performance improvements

fix(csp): add missing analytics domains, remove unsafe-eval, fix workspace CSP gap (#4179)
fix(landing): return 404 for invalid dynamic route slugs (#4182)
improvement(seo): optimize sitemaps, robots.txt, and core web vitals across sim and docs (#4170)
fix(gemini): support structured output with tools on Gemini 3 models (#4184)
feat(brightdata): add Bright Data integration with 8 tools (#4183)
fix(mothership): fix superagent credentials (#4185)
fix(logs): close sidebar when selected log disappears from filtered list; cleanup (#4186)
v0.6.46: mothership streaming fixes, brightdata integration
waleedlatif1 and others added 18 commits April 21, 2026 20:25
…rity hardening, contact page, 404 page, access control, SES, SNS
v0.6.54: migration error logs
…ze, subagent thinking, files sorting, agentphone integration
fix(db): revert statement_timeout startup options breaking pooled connections (#4284)
v0.6.57: mothership reliability, ashby refactor, tables row count, copilot id fix, bun upgrade
…rizations, mothership positional table row insertion, CI improvements, org-external users, file viewer improvements
v0.6.62: fix new copilot chat creation and selection on refresh
…ixes, db query optimizations, contract boundaries code hygiene, CORS, toast improvements, tables infinite query, executor robustness, reranker support
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 4, 2026 8:26pm

Request Review

@gitguardian
Copy link
Copy Markdown

gitguardian Bot commented May 4, 2026

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
29606901 Triggered Generic High Entropy Secret a54dcbe apps/sim/providers/utils.test.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@cursor
Copy link
Copy Markdown

cursor Bot commented May 4, 2026

PR Summary

Medium Risk
Adds a new OpenAI image model and expands request parameter handling, which could affect image generation behavior and API compatibility if defaults/parameter mappings are wrong. Changes are localized to the image generator block and openai_image tool.

Overview
Adds gpt-image-2 support to the Image Generator block and the openai_image tool, including model selection and updated default size behavior (dall-e-3 defaults to 1024x1024, GPT models default to auto).

Introduces GPT-image-specific options for quality (auto/low/medium/high), outputFormat (png/jpeg/webp), and moderation (auto/low, gpt-image-2 only), and wires these through to the OpenAI images/generations request body (including output_format mapping).

Reviewed by Cursor Bugbot for commit b487934. Configure here.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

Closing — recreating with clean history (single commit only).

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 4, 2026

Greptile Summary

This PR adds gpt-image-2 as a third model option in the Image Generator block, wiring up its specific parameters (size options up to 4K, quality auto/low/medium/high, background without transparent, output_format, and moderation) while correctly sharing quality/background/outputFormat sub-blocks with gpt-image-1. It also fixes a pre-existing gap where quality and outputFormat were never forwarded for gpt-image-1.

Confidence Score: 4/5

Safe to merge; only P2 cosmetic/observability findings, no correctness or security issues.

All parameter routing is correct: camelCase→snake_case mapping for output_format, moderation gated to gpt-image-2 only, size defaults updated properly. The two findings are a stale log string and missing outputFormat in response metadata — neither affects functional correctness.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/image_generator.ts Adds gpt-image-2 model support with correct size/quality/background/outputFormat/moderation sub-blocks; fixes missing quality pass-through for gpt-image-1; size fallback logic updated correctly.
apps/sim/tools/openai/image.ts Extends the request body builder to handle gpt-image-2; correctly maps camelCase outputFormat to snake_case output_format; adds moderation gating; the URL-response log still hard-codes "DALL-E 3" — minor cosmetic issue only.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Block: params function] -->|model=dall-e-3| B[quality, style → baseParams]
    A -->|model=gpt-image-1| C[quality, background, outputFormat → baseParams]
    A -->|model=gpt-image-2| D[quality, background, outputFormat, moderation → baseParams]

    B --> E[Tool: body builder]
    C --> E
    D --> E

    E -->|dall-e-3| F[body.quality, body.style]
    E -->|gpt-image-1 or gpt-image-2| G[body.quality, body.background, body.output_format]
    G -->|gpt-image-2 only| H[body.moderation]

    F --> I[POST /v1/images/generations]
    G --> I
    H --> I

    I -->|url| J[Fetch via proxy → base64]
    I -->|b64_json| K[Use directly]
    J --> L[Return image + metadata]
    K --> L
Loading

Comments Outside Diff (2)

  1. apps/sim/tools/openai/image.ts, line 127-129 (link)

    P2 The URL-response log message still hard-codes "DALL-E 3" even after the modelName variable is already in scope. When gpt-image-2 ever returns a URL response this log will be misleading.

  2. apps/sim/tools/openai/image.ts, line 188-197 (link)

    P2 Missing outputFormat in response metadata

    The transformResponse returns metadata: { model } only. When output_format is jpeg or webp, the base64 payload lacks any MIME-type hint, so downstream consumers rendering the raw base64 (e.g. data:image/...;base64,...) won't know the correct content type. Consider echoing outputFormat back through metadata so callers can construct a correct data URI.

Reviews (1): Last reviewed commit: "feat(image-generator): add gpt-image-2 m..." | Re-trigger Greptile

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b487934. Configure here.

...(params.quality && { quality: params.quality }),
...(params.background && { background: params.background }),
...(params.outputFormat && { outputFormat: params.outputFormat }),
...(params.moderation && { moderation: params.moderation }),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicated params logic for gpt-image-1 and gpt-image-2

Low Severity

The gpt-image-1 and gpt-image-2 branches in the block's params function share three identical lines (quality, background, outputFormat spreads), differing only by the extra moderation line. Meanwhile, the tool's body function in image.ts already consolidates these two models into a single else if branch with a nested check for moderation. The block params function could follow the same consolidated pattern, reducing the risk of future changes being applied to one branch but not the other.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b487934. Configure here.

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.

4 participants