ComfyUI Headless: drive it from code

    by Ricardo Faya

    1

    Automate local ComfyUI image generation via the HTTP API with production-ready pipelines and error handling.

    Free

    8 usesSecurity scanned

    Works with the AI Agents you already use

    ComfyUI Headless: drive it from code

    Example session with this skill installed

    Run a photorealistic render of a cyberpunk street using the Qwen-Lightning pipeline and save it as street-render.webp.

    • Read your context and instructions
    • Compiled the comfyui headless
    • Generated the image

    I have submitted the Qwen-2512-Lightning workflow to your local ComfyUI server. The prompt was enriched with photorealistic suffixes to ensure professional lighting and remove unwanted text/logos. The system successfully polled the history API until the job completed and retrieved the resulting image.

    Headless Generation Results

    ParameterValue
    Modelqwen-2512-lightning.safetensors
    Pipelineqwen-2512-lightning
    Resolution1024 x 1024
    Steps / Sampler4 / euler
    CFG1.0
    Prompt IDf9a2b3c4-d5e6-4f7g-8h9i-0j1k2l3m4n5o
    StatusCompleted
    Output Pathoutputs/street-render_00001_.png
    WebP Size38.4 KB (Optimized via FFmpeg)
    
    # Execution log
    # 1. Fetched node signatures from /object_info/UNETLoader
    # 2. Submitting workflow JSON to POST /prompt...
    # 3. Job f9a2b3c4... queued.
    # 4. Polling /history/f9a2b3c4... Done.
    # 5. Retrieving street-render_00001_.png.
    # 6. Optimization: ffmpeg -i in.png -vf scale=1024:-1 -quality 80 street-render.webp
    

    Next steps

    • Inspect the render at the provided output path to check for unwanted artifacts.
    • Scale the batch_size in the run.py arguments if you need multiple variations of this scene.
    • If the lighting is too flat, consider switching to the z-image-base pipeline for higher step counts.

    street-render_00001_.png

    PNG · 1536×1024

    Generated

    Example file from a real run - the skill writes it into your workspace.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    The problem

    Running ComfyUI through the browser canvas is fine for single images but fails for automation. Developers lack clear documentation on the specific HTTP API format, subgraph handling, and error retrieval required for headless production pipelines.

    What it does

    • Submits image generation workflows to the ComfyUI HTTP API using the required flat-dict API format.
    • Extracts and navigates complex subgraphs and muted nodes from modern workflow templates.
    • Polls job history and retrieves output filenames for automated asset pipelines.
    • Provides tested pipelines for Z-Image Turbo, Qwen-Lightning, and LoRA-integrated workflows.
    • Queries the server for exact model filenames and node signatures to prevent validation errors.

    Frameworks & tools

    ComfyUI, Stable Diffusion, Flux, Z-Image, Qwen Image, Python, FFmpeg.

    Why this beats prompting it yourself

    ComfyUI uses two different JSON formats. Simply "saving" a workflow from the UI produces a Graph format that the API rejects. This skill handles the transformation, solves the silent LoRA wiring failure, and correctly parses the HTTP 400 error bodies where ComfyUI hides its validation feedback.

    Use cases

    • Building a backend worker that generates image assets for a web application.
    • Running large-scale batch processing for thousands of variations without manual canvas clicks.
    • Integrating image generation into CI/CD pipelines or nightly cron jobs.
    • Creating a custom interface or agent that controls a local GPU server.

    Known limitations

    Requires a local or reachable ComfyUI server instance. High VRAM usage (8+ GB) is necessary for batching at 1024x1024 resolutions.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    8 uses

    Times used to date

    Free to use

    No account required to browse

    Frequently Asked Questions

    This skill enables you to programmatically control ComfyUI by automating the conversion of standard UI workflows into the specific API format required for headless execution and server-side automation.

    You will need a reachable local or remote ComfyUI server instance and a Python environment; it is designed to work with modern workflow nodes like Flux, Z-Image, and LoRA-integrated pipelines.

    The purchase includes the core logic for API communication, subgraph extraction templates, and tested pipelines for popular models like Qwen-Lightning and Stable Diffusion.

    Yes, this skill is specifically designed to handle batch processing of thousands of image variations through a backend worker, bypassing the need for manual browser-based canvas interactions.

    It solves the 'silent failure' issue by correctly parsing HTTP 400 error bodies and validating node signatures, providing clear feedback that the standard ComfyUI API often hides.

    The skill is designed to be framework-agnostic but is optimized for Python-based AI agents and backend services that require a reliable bridge to a GPU server.

    New in Image & Video

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Image Generation Skills.

    Free