# 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({
"92": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/MiniMax_H3",
"format": "auto",
"format.codec": "auto",
"video": [
"140:130",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"115": {
"class_type": "ResolutionSelector",
"inputs": {
"aspect_ratio": "16:9 (Widescreen)",
"megapixels": 0.4,
"multiple": 32
},
"_meta": {
"title": "Resolution Selector"
}
},
"140:119": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "minimax_h3_video_vae_fp16.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"140:120": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "minimax_h3_audio_vae_fp32.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"140:121": {
"class_type": "VAEDecodeAudio",
"inputs": {
"samples": [
"140:125",
0
],
"vae": [
"140:120",
0
]
},
"_meta": {
"title": "VAE Decode Audio"
}
},
"140:122": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"140:125",
0
],
"vae": [
"140:119",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"140:123": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "res_multistep"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"140:124": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"140:135",
0
],
"scheduler": "simple",
"steps": [
"140:136",
0
]
},
"_meta": {
"title": "BasicScheduler"
}
},
"140:125": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"140:126",
0
],
"latent_image": [
"140:131",
1
],
"noise": [
"140:129",
0
],
"sampler": [
"140:123",
0
],
"sigmas": [
"140:124",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"140:126": {
"class_type": "BasicGuider",
"inputs": {
"conditioning": [
"140:131",
0
],
"model": [
"140:135",
0
]
},
"_meta": {
"title": "Basic Guider"
}
},
"140:127": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "minimax_h3_fl2va_pruned_int8_convrot.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"140:128": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors",
"device": "default",
"type": "minimax"
},
"_meta": {
"title": "Load CLIP"
}
},
"140:129": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 757358688076805
},
"_meta": {
"title": "RandomNoise"
}
},
"140:130": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"140:121",
0
],
"bit_depth": 8,
"codec": "none",
"color_space": "sRGB",
"fps": 24,
"images": [
"140:122",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"140:131": {
"class_type": "MiniMaxH3ImageToVideo",
"inputs": {
"clip": [
"140:128",
0
],
"height": [
"115",
1
],
"length": [
"140:132",
1
],
"prompt": "A low-angle high-speed tracking shot surges alongside a battered matte-olive trophy truck hurtling across a rain-drenched black volcanic gravel plain beneath bruised midday storm clouds. Behind the cracked windshield, an elderly East Asian woman with a stocky build and cropped silver hair fiercely works the steering wheel, wearing a heavy charcoal insulated flight suit. Huge all-terrain tires fling sheets of black water and volcanic silt as a relentless swarm of dark, darting surveillance drones dives in close pursuit through the torrential squall. The camera suddenly whip-pans from the vehicle’s churning wheels up toward the swooping drones piercing the gloom. Cold, diffused slate-gray light illuminates the deluge, punctuated by distant white lightning strikes. Sound of a deafening, throaty V8 engine snarling against the thunderous downpour, tires ripping through gravel, and high-pitched metallic drone turbine whines.",
"vae": [
"140:119",
0
],
"width": [
"115",
0
]
},
"_meta": {
"title": "MiniMax H3 Image to Video"
}
},
"140:132": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "max(5, round(a * 24)) + (5 - (max(5, round(a * 24)) % 17)) % 17",
"values.a": [
"140:133",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"140:133": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 5
},
"_meta": {
"title": "Float (duration)"
}
},
"140:134": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "minimax_h3_fl2v_turbo_8step_v1.0_comfyui_bf16.safetensors",
"model": [
"140:127",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"140:135": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"140:127",
0
],
"on_true": [
"140:134",
0
],
"switch": [
"140:139",
0
]
},
"_meta": {
"title": "If/Else Switch (Model)"
}
},
"140:136": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"140:137",
0
],
"on_true": [
"140:138",
0
],
"switch": [
"140:139",
0
]
},
"_meta": {
"title": "If/Else Switch (Steps)"
}
},
"140:137": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 20
},
"_meta": {
"title": "Int"
}
},
"140:138": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 8
},
"_meta": {
"title": "Int"
}
},
"140:139": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": False
},
"_meta": {
"title": "Boolean (Enable Lightning LoRA)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("92"):
output.to_file(output.name)