ComfyUI Node

LLM Config

The API key hub that feeds every LLM node in this pack

By latentastronaut·Created 8 months ago·Updated 7 months ago· 2
LLM Config
    • llm_config
    providerOpenAI
    modelgpt-4o
    api_key
    custom_endpoint
    max_tokens0

    LLM Config is the pack's "point it at an API and stop asking" node. Every LLM-powered node in this pack (the prompt enhancer being the main one) needs an llm_config before it'll do anything, and this is where that config comes from. Pick a provider, name a model, handle the API key - it packages all of that into a single LLM_CONFIG value you wire anywhere. Nothing runs locally, which is worth stating plainly: this is a key-management and routing node for cloud LLM APIs, not a model runner.

    How it works

    It's pure configuration logic, no network calls at all. Pick a provider and it fills in the known endpoint - OpenAI's api.openai.com/v1, xAI's for Grok, Google's for Gemini. The model string is whatever you want to use with that provider (defaults like gpt-4o and grok-2 are suggested). The api_key handling is the clever part and supports three ways in:

    • Leave it empty - falls back to the provider's standard environment variable (OPENAI_API_KEY, XAI_API_KEY, GOOGLE_API_KEY)
    • $ENV.VAR_NAME - reference any environment variable
    • Type the key directly - works, but the code comments warn it can leak into workflow metadata, which lives in your saved PNGs

    For a Custom provider, custom_endpoint lets you point at any OpenAI-compatible server - that's your ticket to local LLM backends like Ollama or vLLM, or any hosted clone. max_tokens caps the response (0 lets the API decide; some models require an explicit value).

    The inputs

    • provider - OpenAI, Grok, Google, or Custom
    • model - the model name string
    • api_key - direct key, $ENV.VAR_NAME, or empty for the default env var
    • custom_endpoint (optional) - only used for Custom
    • max_tokens (optional) - response cap, default 0 (API decides)

    Output: llm_config, wired into any node that takes LLM_CONFIG input.

    Install

    Pack install via ComfyUI Manager (search "Latent Astronaut Suite") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/latentastronaut/comfyui-latent-astronaut-suite
    

    Restart. On first boot install.py installs the openai and google-genai clients the LLM nodes need.

    Where people get burned

    Forgetting the key entirely is the classic failure - a blank key with no env var set gives you an auth error at generation time, not at config time. The $ENV syntax is the safer habit; hardcoding a key into the node is convenient but the pack's own docs warn it leaks into saved workflow metadata. And note the config node doesn't validate anything - typos in the model name or endpoint fail later, when the enhancer actually calls out.

    Categoryllm/latent-astronaut

    Inputs (5)

    NameTypeDefaultDescription
    providerCOMBOOpenAILLM provider to use
    modelSTRINGgpt-4oModel name (e.g., gpt-4o, grok-2, gemini-1.5-flash)
    api_keySTRINGAPI key, $ENV.VAR_NAME, or leave empty for default env var
    custom_endpointoptSTRINGCustom OpenAI-compatible endpoint URL (for Custom provider)
    max_tokensoptINT00–128000Max tokens in response (0 = let API decide, required for some models)

    Outputs (1)

    NameTypeDescription
    llm_configLLM_CONFIG