Nodes/comfyui-openai-compatible-image/OpenAI Compatible Image Generate
ComfyUI Node

OpenAI Compatible Image Generate

Cloud image gen in ComfyUI with your own key — no Comfy account needed

By wennatre·Created 3 months ago·Updated 3 months ago· 0
OpenAI Compatible Image Generate
    • image
    • response_json
    promptA clean product photo of a translucent glass teapot on a walnut table, soft daylight, realistic.
    api_basehttps://api.openai.com/v1
    modelgpt-image-2
    size1024x1024
    qualityauto
    n1
    timeout_seconds600
    api_key
    endpoint_path/images/generations
    extra_headers_json{}
    extra_body_json{}
    save_raw_responsefalse

    The name is half a lie. This node doesn't generate anything on your machine - it's an HTTP client wearing a ComfyUI costume. You feed it a prompt, it POSTs to any OpenAI-compatible /images/generations endpoint, and drops the returned picture back into your graph as a normal IMAGE tensor. From the canvas it looks like a sampler. Underneath, it's a text-to-image call to a server you don't control.

    Which is the point. Want GPT Image or a reseller's proxy inside a local workflow? Those models have no open weights, so there's no other door. ComfyUI's official API Nodes get you there through prepaid credits and a Comfy account; this node is the bring-your-own-key alternative. Paste your key in, point api_base at whatever endpoint accepts it, and the image keeps flowing into your local upscaler, your masking, your LoRA. One cloud model in the middle of an otherwise-local graph.

    How it works

    Read the source and it's a short story. The node builds a POST {api_base}{endpoint_path} request with a Bearer key from OPENAI_API_KEY (or the api_key field), sends {model, prompt, n} plus size and quality if they're not "auto", and reads the response. The part worth crediting: it's unusually tolerant of response shapes. Real OpenAI returns data[].b64_json; proxies return url, image_url, output_url, or result_url; some return top-level images, outputs, or results arrays. This node checks all of them, decodes base64 or downloads the URL, and stacks the results into a batch tensor. If your provider answers at all, there's a good chance it gets parsed.

    You get two outputs: image (the IMAGE tensor - wire it into a Save Image, or straight into an upscaler) and response_json, the raw response as pretty-printed text. That second one is the debugging tool you'll actually use.

    The inputs that matter

    Most fields you can ignore. The few a beginner sets:

    • prompt - multiline, self-explanatory.
    • api_base - defaults to https://api.openai.com/v1. Point this at any OpenAI-compatible gateway; the endpoint_path field (default /images/generations) lets you keep the rest of the URL.
    • model - free text on purpose. Defaults to gpt-image-2, which is real as of 2026, but proxies often accept whatever string they were built around.
    • quality - auto / low / medium / high. auto just omits the field, so it's safe with endpoints that don't know it.
    • n - 1 to 10 images per call. Each one is a separate billable generation.
    • timeout_seconds - defaults to 600. Leave it alone until it bites you.

    The optional extra_headers_json and extra_body_json are how you satisfy a picky provider - {"x-provider-key": "value"} as a header, {"user": "comfyui"} in the body. save_raw_response dumps the full API response JSON to your temp dir when the console path tells you to look.

    Installing it

    ComfyUI Manager is the easy route if the pack shows up there; otherwise the README's path is direct:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wennatre/ComfyUI-OpenAI-Compatible-Image.git
    pip install -r ComfyUI-OpenAI-Compatible-Image/requirements.txt
    

    The dependencies are just numpy, Pillow, and requests - your ComfyUI env almost certainly already has all three. Then set your key and restart:

    export OPENAI_API_KEY="your_api_key"
    

    On Windows PowerShell: $env:OPENAI_API_KEY="your_api_key". An example workflow in workflows/ imports straight into ComfyUI.

    Troubleshooting

    Two failure modes dominate, both grounded in the README and the code. Timeouts - proxy endpoints can sit on a generation for minutes, and some hold HTTP connections open wrong. The node already sends Connection: close to dodge stale connections; if it still times out, raise timeout_seconds to 900–1200, drop n to 1, and inspect response_json (or enable save_raw_response) to see what the server actually returned.

    The "returned nothing" case is usually a provider with an async job API - it answers with a job ID instead of image data, and this node can't poll. No node can fix that without provider-specific code; the README says so plainly. Check response_json to confirm the shape before you blame the node.

    And the missing-key error (Missing API key) means the env var isn't visible to the ComfyUI process. If you launch from a GUI rather than a terminal, export it from the same shell, or fill in the api_key field.

    One honest warning

    A node whose whole job is to phone home with your key is the exact shape of the thing that got weaponized once in this ecosystem - the LLMVISION incident shipped credential-stealing malware through normal install channels and ended in a federal prosecution. That's not a knock on this pack (single-node, MIT, the code is short enough to read in one sitting - do that). It's context: prefer the env var over pasting a key into the node, because widget values get saved into workflow JSON, and workflows get shared. The key in your graph is a secret until the day you export that graph and it isn't.

    CategoryOpenAI Compatible/Image

    Inputs (12)

    NameTypeDefaultDescription
    promptSTRINGA clean product photo of a translucent glass teapot on a walnut table, soft daylight, realistic.
    api_baseSTRINGhttps://api.openai.com/v1
    modelSTRINGgpt-image-2
    sizeSTRING1024x1024
    qualityCOMBOauto4 options: auto, low, medium, high
    nINT11–10
    timeout_secondsINT60030–3600
    api_keyoptSTRING
    endpoint_pathoptSTRING/images/generations
    extra_headers_jsonoptSTRING{}
    extra_body_jsonoptSTRING{}
    save_raw_responseoptBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    imageIMAGE
    response_jsonSTRING