RunComfy offers two API approaches to suit various integration needs:

RunComfy Server API and ComfyUI Backend API These APIs lets you spin up and fully control a dedicated ComfyUI backend. Start by using the Server API to manage machines through simple calls: POST to generate a server_id, poll the status endpoint until it reaches "Ready", and then access the **ComfyUI Backend API** directly for tasks like executing workflows, managing nodes, and retrieving outputs. This approach is perfect when you need complete oversight of the ComfyUI backend, such as for in-depth integrations with creative software like Krita, Photoshop, Blender, iClone, or other tools.

RunComfy Serverless API This API turns any ComfyUI workflow into an on-demand, autoscaling endpoint, enabling simple API calls without any server setup or maintenance. It includes asynchronous job monitoring and versioning for rapid updates, making it ideal for efficient, scalable production setups that can be easily integrated into your apps. For more details, check our Serverless API documentation.

Get ComfyUI Backend URL

  1. From RunComfy website in the browser
    1. The url appears as https://www.runcomfy.com/comfyui/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/servers/yyyyyyy-yyyy-yyyy-yyyyyyyyyyyy.
    2. The actual ComfyUI URL can be found in here, in a format of https://yyyyyyy-yyyy-yyyy-yyyyyyyyyyyy-comfyui.runcomfy.com.
  2. From RunComfy API
    1. It is the main_service_url in this response.

Note: Please use this ComfyUI URL in a trusted environment, DO NOT SHARE IT publicly.

Activate Development Mode

Ensure that "Enable Development Mode Options" is activated in the Settings menu.

Screenshot 2024-02-23 at 10.32.22.png

Download the workflow_api.json file by clicking on the Save (API Format) button.

The following file is AnimateDiff + ControlNet + Auto Mask | Restyle Video, which will be used as an example.

workflow_api.json

Upload Image as Input

import requests

url = "<https://yyyyyyy-yyyy-yyyy-yyyyyyyyyyyy-comfyui.runcomfy.com/upload/image>"

payload = {'overwrite':'true', 'type':'input', 'subfolder':''} # you can safely remove the subfolder field here if you don't need it
files=[
  ('image',('zzzz.png',open('/folder_path/zzzz.png','rb'),'application/octet-stream'))
]
headers = {}

response = requests.post(url, headers=headers, data=payload, files=files)

print(response.json())

Upload Video as Input

import requests

url = "<https://yyyyyyy-yyyy-yyyy-yyyyyyyyyyyy-comfyui.runcomfy.com/upload/image>"

payload = {'overwrite':'true', 'type':'input', 'subfolder':''} # you can safely remove the subfolder field here if you don't need it
files=[
  ('image',('zzzz.mp4',open('/folder_path/zzzz.mp4','rb'),'application/octet-stream'))
]
headers = {}

response = requests.post(url, headers=headers, data=payload, files=files)

print(response.json())

The response will be something like: