# 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({
"2": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "video/video/MiniMax_H3_Max_turbo_i2v_768P",
"format": "auto",
"format.codec": "auto",
"video": [
"24",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"7": {
"class_type": "MinimaxHailuo03ContextIRNode",
"inputs": {
"first_frame": [
"25",
0
],
"model": "MiniMax H3",
"model.duration": 5,
"model.prompt": [
"14",
0
],
"model.ratio": "adaptive"
},
"_meta": {
"title": "MiniMax H3 Context IR (Prompt Enhancer)"
}
},
"8": {
"class_type": "SaveText",
"inputs": {
"filename_prefix": "H3_prompt",
"format": "txt",
"text": [
"12",
0
]
},
"_meta": {
"title": "Save Text"
}
},
"10": {
"class_type": "MinimaxHailuo03RegenerateNode",
"inputs": {
"first_frame": [
"25",
0
],
"model": "MiniMax H3",
"model.prompt": [
"8",
0
],
"model.resolution": "2K",
"video": [
"2",
0
],
"watermark": False
},
"_meta": {
"title": "MiniMax H3 Regenerate to 2K"
}
},
"11": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "video/Minimax_h3_max",
"format": "auto",
"format.codec": "auto",
"video": [
"13",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"12": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"14",
0
],
"on_true": [
"7",
0
],
"switch": [
"18",
0
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"13": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"24",
0
],
"on_true": [
"10",
0
],
"switch": [
"19",
0
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"14": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "At 0.00 seconds, cinematic live-action arc shot with slow push-in, centered on a futuristic metallic teal aerodynamic sports car parked on a spacious light grey tiled concrete platform. The background features a calm deep blue ocean, clear cloudless sky, and sharp angular dark grey concrete architectural structures. The car adopts sharp angular body lines, slim white LED headlights, geometric front air intakes with delicate copper aerodynamic fins, and fully raised gull-wing doors. It is equipped with black and silver turbine-style alloy wheels, paired with white leather bucket seats with dark grey inserts and a minimalist futuristic interior.\n\nThe camera slowly circles to the right and pushes closer to the vehicle. The sports car performs a smooth and precise mechanical decomposition in mid-air. The metallic teal body panels, gull-wing doors and four turbine wheels float outward steadily. Interior leather seats and central console hover slightly upward, exposing intricate carbon fiber frameworks, metal brake discs, calipers and suspension structures. All disassembled components suspend in orderly spaced mid-air arrangement with stable posture. Ultra-fine surface textures are clearly presented: delicate metallic flakes inside teal paint, fine leather stitching and grain, and high-precision brushed metal finishes, creating a clean, high-tech and realistic mechanical explosion visual effect."
},
"_meta": {
"title": "Text (Prompt)"
}
},
"18": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": False
},
"_meta": {
"title": "Boolean (Prompt Enhance)"
}
},
"19": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": False
},
"_meta": {
"title": "Boolean (Upscale to 2K)"
}
},
"24": {
"class_type": "MinimaxHailuo03FirstLastFrameNode",
"inputs": {
"first_frame": [
"25",
0
],
"model": "MiniMax H3 Max Turbo",
"model.duration": 5,
"model.prompt": [
"12",
0
],
"model.prompt_expansion_mode": "balanced",
"model.resolution": "768P",
"seed": 2188635952,
"watermark": False
},
"_meta": {
"title": "MiniMax H3 First-Last-Frame to Video"
}
},
"25": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("25", "image", client.assets.from_url("https://example.com/replace-with-a-url/image"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)