# 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({
"228": {
"class_type": "ImageScale",
"inputs": {
"crop": "center",
"height": 480,
"image": [
"238",
0
],
"upscale_method": "lanczos",
"width": 720
},
"_meta": {
"title": "Upscale Image"
}
},
"230": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"228",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"235": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI_WanMove",
"format": "auto",
"format.codec": "auto",
"video": [
"257:234",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"238": {
"class_type": "LoadImage",
"inputs": {
"image": "snowboard_rush.png"
},
"_meta": {
"title": "Load Image"
}
},
"244": {
"class_type": "GenerateTracks",
"inputs": {
"bezier": True,
"end_x": 0.22,
"end_y": 0.45,
"height": 480,
"interpolation": "linear",
"mid_x": 0.46,
"mid_y": 0.44,
"num_frames": 81,
"num_tracks": 5,
"start_x": 0.6,
"start_y": 0.27,
"track_spread": 0.007,
"width": 720
},
"_meta": {
"title": "Generate Video Tracks"
}
},
"245": {
"class_type": "GenerateTracks",
"inputs": {
"bezier": True,
"end_x": 0.96,
"end_y": 0.16,
"height": 480,
"interpolation": "linear",
"mid_x": 0.88,
"mid_y": 0.72,
"num_frames": 81,
"num_tracks": 7,
"start_x": 0.48,
"start_y": 0.97,
"track_spread": 0.017,
"width": 720
},
"_meta": {
"title": "Generate Video Tracks"
}
},
"246": {
"class_type": "GenerateTracks",
"inputs": {
"bezier": True,
"end_x": 0.55,
"end_y": 0.63,
"height": 480,
"interpolation": "linear",
"mid_x": 0.42,
"mid_y": 0.96,
"num_frames": 81,
"num_tracks": 5,
"start_x": 0.12,
"start_y": 1,
"track_spread": 0.012,
"width": 720
},
"_meta": {
"title": "Generate Video Tracks"
}
},
"247": {
"class_type": "WanMoveConcatTrack",
"inputs": {
"tracks_1": [
"244",
0
],
"tracks_2": [
"245",
0
]
},
"_meta": {
"title": "WanMoveConcatTrack"
}
},
"248": {
"class_type": "WanMoveConcatTrack",
"inputs": {
"tracks_1": [
"247",
0
],
"tracks_2": [
"246",
0
]
},
"_meta": {
"title": "WanMoveConcatTrack"
}
},
"257:10": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "wan_2.1_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"257:131": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"257:144",
0
],
"vae": [
"257:10",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"257:144": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"257:195",
2
],
"model": [
"257:61",
0
],
"negative": [
"257:195",
1
],
"positive": [
"257:195",
0
],
"sampler_name": "er_sde",
"scheduler": "simple",
"seed": 128,
"steps": 6
},
"_meta": {
"title": "KSampler"
}
},
"257:151": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"257:193",
0
],
"text": "cartoon character walking in a grassy meadow surrounded by trees"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"257:193": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "umt5_xxl_fp8_e4m3fn_scaled.safetensors",
"device": "default",
"type": "wan"
},
"_meta": {
"title": "Load CLIP"
}
},
"257:195": {
"class_type": "WanMoveTrackToVideo",
"inputs": {
"batch_size": 1,
"clip_vision_output": [
"257:83",
0
],
"height": [
"257:226",
1
],
"length": 81,
"negative": [
"257:34",
0
],
"positive": [
"257:151",
0
],
"start_image": [
"228",
0
],
"strength": 1,
"tracks": [
"248",
0
],
"vae": [
"257:10",
0
],
"width": [
"257:226",
0
]
},
"_meta": {
"title": "WanMoveTrackToVideo"
}
},
"257:226": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"228",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"257:231": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "lightx2v_I2V_14B_480p_cfg_step_distill_rank64_bf16.safetensors",
"model": [
"257:232",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"257:232": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "Wan21-WanMove_fp8_scaled_e4m3fn_KJ.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"257:234": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": 16,
"images": [
"257:131",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"257:34": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"257:193",
0
],
"text": "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"257:61": {
"class_type": "ModelSamplingSD3",
"inputs": {
"model": [
"257:231",
0
],
"shift": 5
},
"_meta": {
"title": "ModelSamplingSD3"
}
},
"257:83": {
"class_type": "CLIPVisionEncode",
"inputs": {
"clip_vision": [
"257:84",
0
],
"crop": "center",
"image": [
"228",
0
]
},
"_meta": {
"title": "CLIP Vision Encode"
}
},
"257:84": {
"class_type": "CLIPVisionLoader",
"inputs": {
"clip_name": "clip_vision_h.safetensors"
},
"_meta": {
"title": "Load CLIP Vision"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)