feat(clis/chatgptweb): add ChatGPT web image generation command#973
Merged
jackwener merged 3 commits intojackwener:mainfrom Apr 12, 2026
Merged
Conversation
Add `opencli chatgptweb image` command that generates images using ChatGPT web (GPT-4o image generation) and saves them locally. Features: - Navigates to chatgpt.com/new with full page reload to ensure clean state - Uses Playwright's page.type() for reliable text input in TipTap editor - Closes sidebar if open (covers the chat composer on some layouts) - Polls for response completion (handles thinking/throttling states) - Extracts generated images from DOM (backend-api/estuary/content URLs) - Downloads and saves as PNG/JPEG files to user-specified directory - Supports --op for output directory and --sd to skip download Files: - clis/chatgptweb/image.js: CLI command definition - clis/chatgptweb/utils.js: DOM helpers, send/wait/export functions Works cross-platform (Linux/macOS/Windows) via OpenCLI browser automation.
Contributor
|
Nice addition. The flow makes sense, and I like that it follows the existing One follow-up I noticed, not blocking from my side: the new If you are still touching this PR, I would add those here. Otherwise, a small follow-up PR would also work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
opencli chatgptweb imagecommand that generates images using ChatGPT web (GPT-4o native image generation) and saves them locally to disk.This is the ChatGPT web equivalent of the existing
opencli gemini imagecommand.Motivation
ChatGPT (GPT-4o) supports native image generation that is qualitatively different from DALL-E — it understands context better and produces more coherent results for complex scenes. Providing a CLI interface for this enables:
Approach
The command uses OpenCLI's browser automation (CDP/Puppeteer) to:
chatgpt.com/newwith full page reload to ensure clean statepage.type()for reliable text input into the TipTap editorbackend-api/estuary/content)Key implementation decisions:
chatgptwebsite name: ChatGPT is also available as an Electron Desktop app. Usingchatgptwebas the site name ensures the browser-based implementation is used instead of the Desktop app adapter.chatgpt.com/newwithnetworkidle0to clear React sidebar state that persists across client-side navigations.page.type()overexecCommand: Playwright's native type method is more reliable for the TipTap contenteditable editor than DOM manipulation.Files Changed
clis/chatgptweb/image.jsprompt,--op,--sd)clis/chatgptweb/utils.jssendChatGPTMessage,waitForChatGPTImages,getChatGPTVisibleImageUrls,getChatGPTImageAssetsUsage
Testing
Tested successfully on Linux with the following prompts:
"a small orange cat on a windowsill"— 1024x1536 PNG, 1.9MB ✓"a robot sitting at a desk coding"— 1024x1536 PNG, 2.2MB ✓"a cyberpunk city at night"— 1024x1536 PNG ✓Notes
~/Pictures/chatgpt--sdflag is useful for previewing the result before downloading