# 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({
"17": {
"class_type": "LoadImage",
"inputs": {
"image": "chasing_the_light.png"
},
"_meta": {
"title": "Load Image"
}
},
"20": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/kling_o3_i2v",
"format": "auto",
"format.codec": "auto",
"video": [
"21",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"21": {
"class_type": "KlingOmniProImageToVideoNode",
"inputs": {
"aspect_ratio": "16:9",
"duration": 5,
"generate_audio": True,
"model_name": "kling-v3-omni",
"prompt": "Wide shot of a free‑spirited young woman running toward the camera through a sun‑drenched field, white birds exploding upward all around her like symbols of freedom. Her hair and dress are caught by the wind, captured with crisp focus on her face and light motion blur in the foreground flowers and wings. Vivid colors, bright clear sky, optimistic, uplifting cinematic tone.\n",
"reference_images": [
"17",
0
],
"resolution": "720p",
"seed": 0,
"storyboards": "disabled"
},
"_meta": {
"title": "Kling 3.0 Omni Image to Video"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)