Nodes/comfyui_chatgpt/Chat GPT Image Generation Node
ComfyUI Node

Chat GPT Image Generation Node

Generate gpt-image pictures inside ComfyUI and keep the dialogue going

By SamTyurenkov·Created about a year ago·Updated 4 days ago· 0
Chat GPT Image Generation Node
    • IMAGE
    • STRING
    • STRING
    promptGenerate image based on provided image(s).
    sizeauto
    moderationauto
    qualityauto
    image1
    image2
    response_id

    This is the node that started the whole pack. Sam Tyurenkov posted it to r/comfyui in May 2025 with the honest title "My first node, not much, but still" and an even more honest explanation: he needed OpenAI's image models for backgrounds his local SDXL pipeline couldn't do, and got tired of copy-pasting between the ChatGPT window and ComfyUI.

    So here's the thing to get straight before anything else: the name says "Chat GPT," it sits in your graph like every other node, and it does zero generation locally. This is a cloud-API wrapper. It sends your prompt up to OpenAI's image-generation endpoint, waits for the result, and hands it back as a normal ComfyUI IMAGE tensor. No checkpoint download, no VRAM pressure, no negative prompt. The price of admission is an OPENAI_API_KEY and per-image cost.

    How it works

    Under the hood the node calls OpenAI's Responses API (client.responses.create) with an image_generation tool attached, passing your size, moderation, and quality into the tool's settings. It has two modes, and they're worth understanding because they change what the inputs do:

    • Start a dialogue - a fresh request. Your prompt goes in as text, and you can attach up to two images as context.
    • Continue a dialogue - you feed a response_id from a previous run into the optional input, and the node sends it as previous_response_id instead. Any images you loaded are ignored; the conversation just keeps going, same as chatting with the model.

    The pack also ships a "Convert Image to Base64" utility node, and you'll want it: the image1/image2 inputs are STRING, not IMAGE. They expect base64-encoded PNG data, which is exactly what that utility outputs.

    The inputs that matter

    • prompt - multiline, plain English. The default is "Generate image based on provided image(s)," so it's built to work with reference images, not pure text-to-image.
    • size - auto or one of the presets like 1024x1024 and 1536x1024. Bigger costs more.
    • moderation - auto (standard OpenAI moderation) or low, which skips the moderation pass. This is the knob to reach for when auto keeps refusing things you consider perfectly fine.
    • quality - auto / low / medium / high. Price scales with quality.

    Optional inputs are image1, image2 (base64 strings), and response_id. Outputs are IMAGE (the generated result, wire it into a Save Image node), STRING (the raw API response - it's a big JSON blob, so don't feed it to a text display and expect prose), and STRING (the response ID - this is your handle for continue-dialogue).

    Install

    Same pack as the edit node, so the steps are identical. Easiest route is ComfyUI Manager:

    1. Open Manager → Install Custom Nodes → search comfyui_chatgpt → install → restart ComfyUI.

    Or the manual way:

    cd ComfyUI/custom_nodes
    git clone https://github.com/SamTyurenkov/comfyui_chatgpt
    

    Then restart. The pack pulls in openai, Pillow, numpy, torchvision, and dotenv support - Manager handles those; manually, install openai and python-dotenv in your ComfyUI Python env.

    The one thing neither install path can do for you is the key. The node reads OPENAI_API_KEY from the environment or a .env file in ComfyUI's working directory:

    # in the ComfyUI install folder
    echo "OPENAI_API_KEY=sk-..." > .env
    

    Where people get burned

    • No key set - instant authentication error. Check the .env file before blaming the node.
    • Wiring IMAGE tensors into image1/image2 - they're strings. Route through "Convert Image to Base64" first.
    • A 1x1 black image coming out - that's the node's placeholder when the API returns nothing usable. Usually a prompt the moderation layer rejected or a billing/account issue.
    • Cost and privacy - every image leaves your machine and lands on OpenAI's servers, and you pay per image. That's the trade you're signing up for by using a closed API in a local-first tool; the community's feelings about OpenAI's guardrails have flip-flopped more than once.

    Also worth knowing: this author's pack has grown. It now ships "Banana" nodes too, which do the same trick against Google's Nano Banana API if you'd rather pay Alphabet than OpenAI.

    Categorysd

    Inputs (7)

    NameTypeDefaultDescription
    promptSTRINGGenerate image based on provided image(s).
    sizeCOMBOauto4 options: auto, 1024x1024, 1024x1536, 1536x1024
    moderationCOMBOauto2 options: auto, low
    qualityCOMBOauto4 options: auto, low, medium, high
    image1optSTRING
    image2optSTRING
    response_idoptSTRING

    Outputs (3)

    NameTypeDescription
    IMAGEIMAGE
    STRINGSTRING
    STRINGSTRING