Sign inSign up

runpod/worker-comfyui

By runpod

โ€ขUpdated 21 days ago

Image
11

500K+

runpod/worker-comfyui repository overview

โ worker-comfyui

ComfyUIโ  as a serverless API on RunPodโ 

RunPod


This project allows you to run ComfyUI workflows as a serverless API endpoint on the RunPod platform. Submit workflows via API calls and receive generated images as base64 strings or S3 URLs.

โ Table of Contents


โ Quickstart

  1. ๐Ÿณ Choose one of the available Docker imagesโ  for your serverless endpoint (e.g., runpod/worker-comfyui:<version>-sd3).
  2. ๐Ÿ“„ Follow the Deployment Guideโ  to set up your RunPod template and endpoint.
  3. โš™๏ธ Optionally configure the worker (e.g., for S3 upload) using environment variables - see the full Configuration Guideโ .
  4. ๐Ÿงช Pick an example workflow from test_resources/workflows/โ  or get your ownโ .
  5. ๐Ÿš€ Follow the Usageโ  steps below to interact with your deployed endpoint.

โ Available Docker Images

These images are available on Docker Hub under runpod/worker-comfyui:

  • runpod/worker-comfyui:<version>-base: Clean ComfyUI install with no models.
  • runpod/worker-comfyui:<version>-flux1-schnell: Includes checkpoint, text encoders, and VAE for FLUX.1 schnellโ .
  • runpod/worker-comfyui:<version>-flux1-dev: Includes checkpoint, text encoders, and VAE for FLUX.1 devโ .
  • runpod/worker-comfyui:<version>-sdxl: Includes checkpoint and VAEs for Stable Diffusion XLโ .
  • runpod/worker-comfyui:<version>-sd3: Includes checkpoint for Stable Diffusion 3 mediumโ .

Replace <version> with the current release tag, check the releases pageโ  for the latest version.

โ API Specification

The worker exposes standard RunPod serverless endpoints (/run, /runsync, /health). By default, images are returned as base64 strings. You can configure the worker to upload images to an S3 bucket instead by setting specific environment variables (see Configuration Guideโ ).

Use the /runsync endpoint for synchronous requests that wait for the job to complete and return the result directly. Use the /run endpoint for asynchronous requests that return immediately with a job ID; you'll need to poll the /status endpoint separately to get the result.

โ Input
{
  "input": {
    "workflow": {
      "6": {
        "inputs": {
          "text": "a ball on the table",
          "clip": ["30", 1]
        },
        "class_type": "CLIPTextEncode",
        "_meta": {
          "title": "CLIP Text Encode (Positive Prompt)"
        }
      }
    },
    "images": [
      {
        "name": "input_image_1.png",
        "image": "data:image/png;base64,iVBOR..."
      }
    ]
  }
}

The following tables describe the fields within the input object:

Field PathTypeRequiredDescription
inputObjectYesTop-level object containing request data.
input.workflowObjectYesThe ComfyUI workflow exported in the required formatโ .
input.imagesArrayNoOptional array of input images. Each image is uploaded to ComfyUI's input directory and can be referenced by its name in the workflow.
input.comfy_org_api_keyStringNoOptional per-request Comfy.org API key for API Nodes. Overrides the COMFY_ORG_API_KEY environment variable if both are set.
โ input.images Object

Each object within the input.images array must contain:

Field NameTypeRequiredDescription
nameStringYesFilename used to reference the image in the workflow (e.g., via a "Load Image" node). Must be unique within the array.
imageStringYesBase64 encoded string of the image. A data URI prefix (e.g., data:image/png;base64,) is optional and will be handled correctly.

Note

Size Limits: RunPod endpoints have request size limits (e.g., 10MB for /run, 20MB for /runsync). Large base64 input images can exceed these limits. See RunPod Docsโ .

โ Output

Warning

Breaking Change in Output Format (5.0.0+)

Versions < 5.0.0 returned the primary image data (S3 URL or base64 string) directly within an output.message field. Starting with 5.0.0, the output format has changed significantly, see below

{
  "id": "sync-uuid-string",
  "status": "COMPLETED",
  "output": {
    "images": [
      {
        "filename": "ComfyUI_00001_.png",
        "type": "base64",
        "data": "iVBORw0KGgoAAAANSUhEUg..."
      }
    ]
  },
  "delayTime": 123,
  "executionTime": 4567
}
Field PathTypeRequiredDescription
outputObjectYesTop-level object containing the results of the job execution.
output.imagesArray of ObjectsNoPresent if the workflow generated images. Contains a list of objects, each representing one output image.
output.errorsArray of StringsNoPresent if non-fatal errors or warnings occurred during processing (e.g., S3 upload failure, missing data).
โ output.images

Each object in the output.images array has the following structure:

Field NameTypeDescription
filenameStringThe original filename assigned by ComfyUI during generation.
typeStringIndicates the format of the data. Either "base64" or "s3_url" (if S3 upload is configured).
dataStringContains either the base64 encoded image string or the S3 URL for the uploaded image file.

Note

The `output.images` field provides a list of all generated images (excluding temporary ones).
  • If S3 upload is not configured (default), type will be "base64" and data will contain the base64 encoded image string.
  • If S3 upload is configured, type will be "s3_url" and data will contain the S3 URL. See the Configuration Guideโ  for an S3 example response.
  • Clients interacting with the API need to handle this list-based structure under output.images.

โ Usage

To interact with your deployed RunPod endpoint:

  1. Get API Key: Generate a key in RunPod User Settingsโ  (API Keys section).
  2. Get Endpoint ID: Find your endpoint ID on the Serverless Endpointsโ  page or on the Overview page of your endpoint.
โ Generate Image (Sync Example)

Send a workflow to the /runsync endpoint (waits for completion). Replace <api_key> and <endpoint_id>. The -d value should contain the JSON input described aboveโ .

curl -X POST \
  -H "Authorization: Bearer <api_key>" \
  -H "Content-Type: application/json" \
  -d '{"input":{"workflow":{... your workflow JSON ...}}}' \
  https://api.runpod.ai/v2/<endpoint_id>/runsync

You can also use the /run endpoint for asynchronous jobs and then poll the /status to see when the job is done. Or you add a webhook into your requestโ  to be notified when the job is done.

Refer to test_input.jsonโ  for a complete input example.

โ Getting the Workflow JSON

To get the correct workflow JSON for the API:

  1. Open ComfyUI in your browser.
  2. In the top navigation, select Workflow > Export (API)
  3. A workflow.json file will be downloaded. Use the content of this file as the value for the input.workflow field in your API requests.

โ SSH Access

To enable SSH access to the worker, set the PUBLIC_KEY environment variable to your SSH public key. The worker will start an SSH server automatically. Make sure to expose port 22 in your RunPod template so you can connect.

โ Further Documentation

Tag summary

Content type

Image

Digest

sha256:9aa496da3โ€ฆ

Size

35.1 GB

Last updated

21 days ago

docker pull runpod/worker-comfyui:5.10.0-flux1-dev