Nodes/lf-nodes/Stability AI (Image Gen)
ComfyUI Node

Stability AI (Image Gen)

SDXL from the cloud, wired into your graph

By lucafoscili·Created 2 years ago·Updated 6 days ago· 35
Stability AI (Image Gen)
    • images
    prompt
    modelstable-diffusion-xl-1024-v1-0
    negative_prompt
    width512
    height512
    steps20
    cfg_scale7.0
    samples1
    style_preset
    timeout120

    Some machines just can't run SDXL locally, and some people want the convenience of a hosted API without leaving ComfyUI. LF_StabilityAPI is the lf-nodes wrapper around Stability AI's hosted text-to-image endpoint: you type a prompt, it calls api.stability.ai, and a finished image tensor lands back in your graph as if a local sampler had made it. It's the node that answers "can I get SDXL from the cloud inside my workflow?" - with one important catch, which we'll get to, because it's a doozy.

    How it works

    The node builds a text-to-image request - prompt, optional negative prompt, model, size, steps, CFG, sample count, optional style preset - and posts it to a proxy rather than to Stability directly. The proxy (the pack's /lf-nodes/proxy/stability route) is what holds your API key and injects it as the Authorization header, so the key never touches the browser or the graph. The response comes back as base64 artifacts, which the node decodes into IMAGE tensors.

    The catch: that proxy doesn't exist out of the box. The proxy lives in the pack's Workflow Runner, which is opt-in and disabled by default. With a stock install, this node raises "No proxy URL configured" immediately. To actually use it you need to either:

    • set WORKFLOW_RUNNER_ENABLED=true before starting ComfyUI (which activates the runner and its proxy routes), and
    • set STABILITY_API_KEY (or STABILITY_API_KEY_FILE pointing at a file containing it),
    • or set STABILITY_PROXY_URL to point at your own proxy implementing the same contract.

    There's also an optional LF_PROXY_SECRET - if set, requests must carry the X-LF-Proxy-Secret header, which the node sends when the env var is present. Default model is stable-diffusion-xl-1024-v1-0; you can override with any model id the API accepts.

    The inputs that matter

    • prompt (STRING, required) - the only required input. Empty prompts fail with a clear error.
    • negative_prompt (STRING) - sent as a weight −1 prompt.
    • width / height (INT, 64–2048, default 512) - output size. Remember the API is your bottleneck now; 1024+ costs more and takes longer than 512.
    • steps (INT, 10–150, default 20), cfg_scale (FLOAT, 0–35, default 7), samples (INT, 1–10) - the standard diffusion knobs, sent to the API as-is.
    • style_preset (enum, 18 options) - "cinematic", "photographic", "anime", "neon-punk" and friends. A freebie layer of API-side styling.
    • timeout (INT, default 120s) - how long to wait; image generation genuinely can take this long.

    Output is images (IMAGE) - your generated batch, ready to feed a preview or a save node.

    Install

    Pack-level install applies:

    • ComfyUI Manager: search "LF Nodes", install, restart.
    • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/lucafoscili/lf-nodes.git, restart.

    Then the setup above: enable the runner, set the key, restart. The pack's requirements.txt includes the HTTP machinery you need; no model downloads (the model runs on Stability's GPU, not yours).

    Common issues

    • "No proxy URL configured" - the #1 issue, and it's the opt-in gotcha above. Enable the runner and set STABILITY_PROXY_URL, or you're done before you start.
    • "Stability API error: 401 / 403" - the key isn't reaching the proxy. Check STABILITY_API_KEY (or the _FILE variant) is set in the environment ComfyUI actually starts with, and that the proxy is enabled so it can read it.
    • Cost reality check. This is a metered cloud call - every run spends money. The API-wrapper node pattern is great when the model can't run locally, but if SDXL does fit on your card, the local sampler is free after electricity. Worth being honest about which bucket you're in.
    • It's a network node with a credential. The KB's standing advice applies: it's from an established, actively-maintained pack rather than a stranger's one-off, but any node that ships a key and phones home is the shape to be careful with. Set LF_PROXY_SECRET so your proxy demands the header, and don't paste keys into workflow files.
    Category✨ LF Nodes/LLM

    Inputs (10)

    NameTypeDefaultDescription
    promptSTRINGText prompt to generate image from.
    modeloptSTRINGstable-diffusion-xl-1024-v1-0Stability AI model to use for generation.
    negative_promptoptSTRINGNegative prompt to avoid in generation.
    widthoptINT51264–2048Width of generated image.
    heightoptINT51264–2048Height of generated image.
    stepsoptINT2010–150Number of diffusion steps.
    cfg_scaleoptFLOAT7.00–35Classifier-free guidance scale.
    samplesoptINT11–10Number of images to generate.
    style_presetoptCOMBOStyle preset to use for generation.
    timeoutoptINT120Request timeout in seconds.

    Outputs (1)

    NameTypeDescription
    imagesIMAGEGenerated images from Stability AI.