Nodes/ComfyUI-DataSet/DataSet_OpenAIChat
ComfyUI Node

DataSet_OpenAIChat

Prompt Generation Without Leaving ComfyUI

By daxcay·Created 2 years ago·Updated about a year ago· 58
DataSet_OpenAIChat
    • STRING
    â—„modelgpt-3.5-turboâ–º
    â—„api_urlhttps://api.openai.com/v1â–º
    â—„promptâ–º
    â—„token_length1024â–º

    DataSet_OpenAIChat is the original of the pack's API-chat family: type a prompt into a widget, hit queue, and get GPT's reply as a STRING you can route anywhere in your graph. The README's use case is prompt generation - "use the OpenAI GPT chat to help you generate prompts" - and that's the honest way to think about it. It's a text-in/text-out LLM node with the least amount of ceremony.

    Of the three chat providers in this pack, this is the most flexible and the most expensive. It's also the only one that lets you point at a different endpoint, which turns out to matter more than it sounds.

    Inputs

    • model - dropdown of the older GPT lineup: gpt-4, gpt-4-32k, gpt-3.5-turbo, gpt-4-turbo-preview, and the 2023-era previews. Note there's no gpt-4o here - that lives in the image variant.
    • api_url - defaults to https://api.openai.com/v1. This is the sleeper feature: because Groq, Together, OpenRouter, and a pile of local servers expose OpenAI-compatible endpoints, you can point this at any of them and use the node as a generic LLM client. Free Groq Llama through this node? Yes, that works.
    • prompt - the actual request, multiline.
    • token_length - response cap, default 1024.

    Output is a single STRING with the model's reply.

    The key situation, once more

    There's no api_key input. The node reads OPENAI_API_KEY from the environment - set it before launching ComfyUI:

    export OPENAI_API_KEY=sk-...
    

    and restart. If it's missing, the node doesn't crash; it returns a STRING that says "OpenAI API key is required." That string-as-error convention is the pack-wide gotcha, and it's especially easy to miss here because the message is so polite it reads like a caption.

    How it works

    It uses the official openai Python client, sends a hardcoded system message ("You are GPT-4") plus your prompt, and returns response.choices[0].message.content. Nothing clever, no conversation history - each run is a stateless single exchange. If you need a different system persona, fold it into the prompt itself.

    Installing

    Pack standard:

    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-DataSet.git
    cd ComfyUI-DataSet && pip install -r requirements.txt
    

    Restart after. The openai package comes from requirements.txt.

    The realistic review: this node is a couple of years old and the model list is frozen in the 2023-2024 era, so don't expect gpt-4o in the text variant. But the api_url override means it hasn't aged out - point it at whatever current model your endpoint of choice serves, and it's still a perfectly good way to generate or rewrite prompts on the fly. Use it for brainstorming prompts, normalizing caption text, or as the cheap text arm of a dataset pipeline alongside the vision nodes.

    Category🔶DATASET🔶

    Inputs (4)

    NameTypeDefaultDescription
    modelCOMBOgpt-3.5-turbo7 options: gpt-4, gpt-4-32k, gpt-3.5-turbo, gpt-4-0125-preview, gpt-4-turbo-preview, gpt-4-1106-preview, +1
    api_urlSTRINGhttps://api.openai.com/v1—
    promptSTRING—
    token_lengthINT1024—

    Outputs (1)

    NameTypeDescription
    STRINGSTRING—