# 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({
"5": {
"class_type": "PixverseV6FusionVideoNode",
"inputs": {
"model": "PixVerse V6",
"model.aspect_ratio": "16:9",
"model.duration_seconds": 5,
"model.generate_audio": True,
"model.negative_prompt": "",
"model.prompt": "Youthful streetwear ad, two shots, consistent characters and palette throughout.\n\nShot 1 (wide): @Subject1, the young man in a white sweatshirt, black joggers, yellow-orange socks and chunky white sneakers with transparent bubble soles, strides along a neon-lit wall glowing green-to-cyan at night, collar headphones on, walking with rhythm as the neon light washes over him. Low-angle tracking shot.\n\nShot 2 (medium): Fast cut. @Subject2, the girl with long cyan hair, tie-dye tee, tiger-striped and slime-green sleeves, fuzzy orange gloves, rides her BMX with cow-print handlebars around the corner and glides to a stop beside @Subject1. She hops off, they both look down at his sneakers, and the bubble soles flash once in the neon light as they step forward together. Camera pulls back into a wide two-shot under the neon glow.\n\nUpbeat funk-pop track with claps, bike freewheel clicking in Shot 2, sneakers squeaking on pavement, one deep bass hit when they land together. Youthful energetic street-ad mood, consistent green-cyan neon palette across shots.这个提示词里面,角色一跟角色二的这个,嗯",
"model.quality": "720p",
"model.seed": 580678086,
"model.style": "none",
"subjects.subject1": [
"8",
0
],
"subjects.subject2": [
"7",
0
]
},
"_meta": {
"title": "PixVerse V6 Fusion (Reference to Video)"
}
},
"7": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_subject2_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"8": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_subject1_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"10": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "video/PixVerse_v6_r2v",
"format": "auto",
"format.codec": "auto",
"video": [
"5",
0
]
},
"_meta": {
"title": "Save Video"
}
}
})
workflow.set_input("8", "image", client.assets.from_url("https://comfy.org/catalog-media/0878ab39-caed-4808-9129-11b3de805d94/79ac2cb3-a2f8-4052-8536-29d3906482ab"))
workflow.set_input("7", "image", client.assets.from_url("https://comfy.org/catalog-media/fab83f64-74c8-47b4-95a3-2ef31b557051/5629c22a-cdb8-487b-8582-47086d21c85c"))
# 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("10"):
output.to_file(output.name)