# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"1": {
"class_type": "LineArtPreprocessor",
"inputs": {
"coarse": "disable",
"image": [
"2",
0
],
"resolution": 1024
},
"_meta": {
"title": "Realistic Lineart"
}
},
"2": {
"class_type": "VHS_LoadVideo",
"inputs": {
"custom_height": 0,
"custom_width": 0,
"force_rate": 0,
"format": "AnimateDiff",
"frame_load_cap": 48,
"select_every_nth": 1,
"skip_first_frames": 0,
"video": "utility-lineart-video-input.mp4"
},
"_meta": {
"title": "Load Video (Upload) 🎥🅥🅗🅢"
}
},
"3": {
"class_type": "VHS_VideoCombine",
"inputs": {
"crf": 12,
"filename_prefix": "AnimateDiff",
"format": "video/h264-mp4",
"frame_rate": [
"4",
0
],
"images": [
"1",
0
],
"loop_count": 0,
"pingpong": False,
"pix_fmt": "yuv420p",
"save_metadata": True,
"save_output": True,
"trim_to_audio": False
},
"_meta": {
"title": "Video Combine 🎥🅥🅗🅢"
}
},
"4": {
"class_type": "VHS_VideoInfo",
"inputs": {
"video_info": [
"2",
3
]
},
"_meta": {
"title": "Video Info 🎥🅥🅗🅢"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)