ComfyICU API Documentation

Take your custom ComfyUI workflows to production. Run ComfyUI workflows using our easy-to-use REST API. Focus on building next-gen AI experiences rather than on maintaining own GPU infrastructure.

Getting API Key

You can generate API key from your account settings page. Add the key to environment variable.

export COMFYICU_API_KEY=XXX

Then create a new workflow from ComfyICU website and copy the workflow_id.

Running workflow

Note that only files saved to /output/ directory are considered as output of a run. Temporary files produced by PreviewImage nodes will not be saved.

const fetch = require('node-fetch');

async function runWorkflow(workflow_id, prompt, files){
    const url = "https://comfy.icu/api/v1/workflows/"+workflow_id+"/runs"
    const resp = await fetch(url, {
      "headers": {
        "accept": "application/json",
        "content-type": "application/json",
        "authorization": "Bearer " + process.env.COMFYICU_API_KEY
      },
      "body": JSON.stringify({ prompt, files }),
      "method": "POST"
    });
  
    console.log(await resp.json())
}

const prompt = {
    // ComfyUI API JSON
}

const files = {
    "/input/image.jpg": "http://public-url-for-assets.com/image.jpg"
}

runWorkflow("dyhnZYLJjqJ2e6wlStQHq", prompt, files)

Getting status of the run

const fetch = require('node-fetch');

async function getRunStatus(workflow_id, run_id) {
    const url = "https://comfy.icu/api/v1/workflows/"+workflow_id+"/runs/"+run_id
    const resp = await fetch(url, {
    "headers": {
        "accept": "application/json",
        "content-type": "application/json",
        "authorization": "Bearer " + process.env.COMFYICU_API_KEY
    }
    });
    console.log(await resp.json())
}

getRunStatus("dyhnZYLJjqJ2e6wlStQHq", "8kpyVxYD8o8AFyzeTri3P")

Adding custom models, loras

const prompt = {
    // ComfyUI API JSON
    // ...
    "43": {
        "inputs": {
            "clip": [
                "4",
                1
            ],
            "model": [
                "4",
                0
            ],
            "lora_name": "thickline_fp16.safetensors", // specify the lora filename
            "strength_clip": 1,
            "strength_model": 1
        },
        "class_type": "LoraLoader"
    },
    // ...
}

const files = {
    // ...
    "/models/loras/thickline_fp16.safetensors": "https://civitai.com/api/download/models/16368" // direct link to download the lora
}

runWorkflow("dyhnZYLJjqJ2e6wlStQHq", prompt, files)