Nodes/ComfyUI-NS-Util/Simple LLM Config: OpenAI
ComfyUI Node

Simple LLM Config: OpenAI

The default dials, with gpt-4.1-mini already picked for you

By NakamuraShippo·Created about a year ago·Updated 4 months ago· 5
Simple LLM Config: OpenAI
    • LLM_CONFIG
    modelgpt-4.1-mini
    temperature0.7
    max_tokens2000
    api_key

    This is the config node most people hit first when they open this pack's LLM family, because OpenAI is the default answer to "which provider do I use?" Simple LLM Config: OpenAI builds the LLM_CONFIG object that points a workflow at OpenAI's chat API - provider, model, temperature, token cap. It's a plain settings node; the network call happens later, when you feed this into an agent and run a prompt.

    The default model, gpt-4.1-mini, is a genuinely good pick and not just a default-for-default's-sake. It's cheap enough to experiment with and plenty smart for prompt-building, summarizing, and workflow logic. The dropdown also includes gpt-4.1 and gpt-4o for bigger jobs, gpt-4o-mini/gpt-4.1-nano for ultra-cheap work, and the reasoning models o3-mini and o4-mini if you want the model to think out loud before answering - at the cost of speed.

    How it works

    The node packs driver: "openai" with your model, temperature, and max_tokens into a dict and emits LLM_CONFIG. At run time the pack's OpenAI driver POSTs to OpenAI's /v1/chat/completions using plain requests - no OpenAI SDK required. For the key it checks the api_key input, then falls back to the OPENAI_API_KEY environment variable. One quirk: the reasoning models (o3-mini, o4-mini) get the same temperature/max_tokens treatment as the chat models, which isn't how OpenAI's own API ideally wants them handled - expect some quirks on those two.

    The inputs that matter

    • model - seven-option dropdown, default gpt-4.1-mini. Start there; go up to gpt-4.1 when quality matters more than cost.
    • temperature - 0 to 2.0, default 0.7. Lower for deterministic, structured output.
    • max_tokens - 1 to 16384, default 2000. The reply-length cap.
    • api_key (optional) - leave blank and use the OPENAI_API_KEY env var instead. Keys typed into widgets get embedded in saved workflow files and shipped around with them - a real leak vector when you share workflow images.

    Output: a single LLM_CONFIG that feeds Simple LLM Agent or Simple LLM: Agent with Rules.

    Installing the pack

    # ComfyUI Manager → Install via Git URL:
    https://github.com/NakamuraShippo/ComfyUI-NS-Util
    
    # or:
    cd ComfyUI/custom_nodes
    git clone https://github.com/NakamuraShippo/ComfyUI-NS-Util
    pip install pyyaml watchdog
    

    Restart ComfyUI. No model downloads - cloud provider. Pack requirements are just pyyaml/watchdog/opencv. ComfyUI 0.3+ recommended.

    Common issues

    "Error: OpenAI API key not set" at run time means the env var is missing or empty - set OPENAI_API_KEY or fill the widget. If o3-mini/o4-mini misbehave (rejected requests, odd output), that's the reasoning-model quirk above; fall back to gpt-4.1-mini unless you specifically need them. And if a long reply cuts off, raise max_tokens rather than re-running.

    CategoryNS/LLM/Config

    Inputs (4)

    NameTypeDefaultDescription
    modelCOMBOgpt-4.1-mini7 options: gpt-4.1-nano, gpt-4.1-mini, gpt-4.1, gpt-4o-mini, gpt-4o, o4-mini, +1
    temperatureFLOAT0.70–2
    max_tokensINT20001–16384
    api_keyoptSTRING

    Outputs (1)

    NameTypeDescription
    LLM_CONFIGLLM_CONFIG