The Comfy workflow for Wan 2.2 14B turns a starting image into an 81-frame, 720p video. Here, we’ll run it from Python with the Comfy SDK: load the image, submit the prepared graph, and save the result locally.
This approach requires a paid Cloud plan and credits. The local alternative is to use the Wan 2.2 templates built into ComfyUI; for the 14B model, published figures recommend 40 GB or more of memory for 720p with FP8. The Cloud example uses FP8 files and a four-step LoRA.
flowchart TD A["Starting image"] --> B["Upload asset"] B --> C["Wan 2.2 I2V graph"] C --> D["Comfy Cloud job"] D --> E["Save video"]
Set up access
The Comfy workflow runs on the Cloud service, not on your local GPU. Install the SDK version used by the official example and set the key in an environment variable so the script doesn’t leave it written inside the file.
python -m pip install comfy-sdk==0.4.0
In a terminal, set COMFY_API_KEY before running the program. On Bash-compatible systems, use this command:
export COMFY_API_KEY="TU_CLAVE_DE_COMFY"
python wan_i2v.py
Save the following code as wan_i2v.py. Replace the example URL with the accessible address of your own image. The script uploads that image as a Comfy Cloud asset and uses the service https://cloud.comfy.org.
Build and submit the workflow
The graph uses two diffusion models: one for the early, noisier steps and another for the later steps. It also loads the UMT5 encoder and VAE; the filenames must match the models available in the environment running the workflow.
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key:
raise RuntimeError("Define COMFY_API_KEY before running the script")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"97": {
"class_type": "LoadImage",
"inputs": {"image": "UPLOADED_image_FILENAME"},
"_meta": {"title": "Start Frame Image"}
},
"108": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/Wan2.2_image_to_video",
"format": "auto",
"format.codec": "auto",
"video": ["116:94", 0]
},
"_meta": {"title": "Save Video"}
},
"116:101": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "wan2.2_i2v_lightx2v_4steps_lora_v1_high_noise.safetensors",
"model": ["116:95", 0],
"strength_model": 1.0
},
"_meta": {"title": "Load LoRA"}
},
"116:102": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "wan2.2_i2v_lightx2v_4steps_lora_v1_low_noise.safetensors",
"model": ["116:96", 0],
"strength_model": 1.0
},
"_meta": {"title": "Load LoRA"}
},
"116:103": {
"class_type": "ModelSamplingSD3",
"inputs": {"model": ["116:102", 0], "shift": 5.0},
"_meta": {"title": "ModelSamplingSD3"}
},
"116:104": {
"class_type": "ModelSamplingSD3",
"inputs": {"model": ["116:101", 0], "shift": 5.0},
"_meta": {"title": "ModelSamplingSD3"}
},
"116:84": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "umt5_xxl_fp8_e4m3fn_scaled.safetensors",
"device": "default",
"type": "wan"
},
"_meta": {"title": "Load CLIP"}
},
"116:85": {
"class_type": "KSamplerAdvanced",
"inputs": {
"add_noise": "disable",
"cfg": 1,
"end_at_step": 4,
"latent_image": ["116:86", 0],
"model": ["116:103", 0],
"negative": ["116:98", 1],
"noise_seed": 0,
"positive": ["116:98", 0],
"return_with_leftover_noise": "disable",
"sampler_name": "euler",
"scheduler": "simple",
"start_at_step": 2,
"steps": 4
},
"_meta": {"title": "KSampler (Advanced)"}
},
"116:86": {
"class_type": "KSamplerAdvanced",
"inputs": {
"add_noise": "enable",
"cfg": 1,
"end_at_step": 2,
"latent_image": ["116:98", 2],
"model": ["116:104", 0],
"negative": ["116:98", 1],
"noise_seed": 950349635748642,
"positive": ["116:98", 0],
"return_with_leftover_noise": "enable",
"sampler_name": "euler",
"scheduler": "simple",
"start_at_step": 0,
"steps": 4
},
"_meta": {"title": "KSampler (Advanced)"}
},
"116:87": {
"class_type": "VAEDecode",
"inputs": {"samples": ["116:85", 0], "vae": ["116:90", 0]},
"_meta": {"title": "VAE Decode"}
},
"116:89": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": ["116:84", 0],
"text": "blurry motion, flickering, inconsistent lighting, morphing faces, watermark"
},
"_meta": {"title": "CLIP Text Encode (Negative Prompt)"}
},
"116:90": {
"class_type": "VAELoader",
"inputs": {"vae_name": "wan_2.1_vae.safetensors"},
"_meta": {"title": "Load VAE"}
},
"116:93": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": ["116:84", 0],
"text": "A person in a raincoat walks slowly along a city street at night. Rain falls, reflections shimmer on wet pavement, and the camera makes a slow dolly in. Cinematic lighting, smooth natural motion, shallow depth of field."
},
"_meta": {"title": "CLIP Text Encode (Positive Prompt)"}
},
"116:94": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": 16,
"images": ["116:87", 0]
},
"_meta": {"title": "Create Video"}
},
"116:95": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "wan2.2_i2v_high_noise_14B_fp8_scaled.safetensors",
"weight_dtype": "default"
},
"_meta": {"title": "Load High Noise Model"}
},
"116:96": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "wan2.2_i2v_low_noise_14B_fp8_scaled.safetensors",
"weight_dtype": "default"
},
"_meta": {"title": "Load Low Noise Model"}
},
"116:98": {
"class_type": "WanImageToVideo",
"inputs": {
"batch_size": 1,
"height": 720,
"length": 81,
"negative": ["116:89", 0],
"positive": ["116:93", 0],
"start_image": ["97", 0],
"vae": ["116:90", 0],
"width": 1280
},
"_meta": {"title": "WanImageToVideo"}
}
})
image_url = "https://example.com/mi-imagen.jpg"
image_asset = client.assets.from_url(image_url)
workflow.set_input("97", "image", image_asset)
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("108"):
output.to_file(output.name)
print(f"Video saved to: {output.name}") Adjust the motion and image
The WanImageToVideo node sets the size to 1280 × 720 and 81 frames. To change it, edit width, height, and length in that node. The image-to-video workflow lets you adjust the size and total number of frames there.
The positive prompt describes the action and the camera; there’s no need to narrate the entire image again. If the photo shows a person, for example, describe how they turn or move and add a specific camera instruction, such as “slow dolly in” or “pan left”. Wan’s guide recommends avoiding contradictory instructions and using cinematography terms to direct motion.
You can change the negative prompt in the text field of node 116:89; likewise, edit the main description in 116:93. To use a different image, replace the input URL with another one that Comfy Cloud can retrieve.
Common errors that stop the workflow
If the program stops before submitting the job, check that COMFY_API_KEY is set and that the account has a paid plan and credits. Don’t include the key in the code or share it with the file.
The workflow loads two I2V checkpoints, the umt5_xxl_fp8_e4m3fn_scaled.safetensors encoder, the VAE, and the two specified LoRAs. Check that the required files are available in the Comfy Cloud environment and that the input image is accessible at the configured URL.
Finally, don’t automatically resubmit a request if you don’t know whether the previous one finished: Comfy warns that each submission may start a paid run. Check the job status before launching it again.
Once the result is saved, you can iterate one variable at a time: the prompt’s motion, the starting image, or the video dimensions. The workflow exposes these controls and preserves Wan 2.2’s two-stage structure.
Sources: thundercompute.com, ComfyUI, Comfy, Yotta Labs