# 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({
"1": {
"class_type": "LoadImage",
"inputs": {
"image": "api_pruna_p_video_2_pro_avatar_input_female_warrior.png"
},
"_meta": {
"title": "Load Image"
}
},
"2": {
"class_type": "PrunaAvatarNode",
"inputs": {
"enhance_prompt": True,
"image": [
"1",
0
],
"prompt": "She speaks straight to camera with calm warmth, a slow blink and a small nod on the final words, the morning light from the window drifting across her cheek; the camera holds steady at eye level.",
"resolution": "768p",
"seed": 42,
"speech": "script",
"speech.language": "English (US)",
"speech.script": "Every face carries a story. Sit with me for a moment, and I will tell you mine. It begins with a long white hallway, and a window full of morning light.",
"speech.voice": "Zephyr (Female)",
"speech.voice_prompt": "Warm, unhurried, a little wry."
},
"_meta": {
"title": "Pruna P-Video-2 Pro Avatar"
}
},
"3": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "api_pruna_p_video_2_pro_avatar",
"format": "auto",
"format.codec": "auto",
"video": [
"2",
0
]
},
"_meta": {
"title": "Save Video"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)