# 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({
"29": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "kling_o3_image",
"images": [
"30",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"30": {
"class_type": "KlingOmniProImageNode",
"inputs": {
"aspect_ratio": "16:9",
"model_name": "kling-v3-omni",
"prompt": "A candid, high-fashion photograph of two stylish women captured mid-motion in a bustling Parisian courtyard. The woman in the pink ruffled blouse laughs softly, turning her head slightly, while the woman in the tweed blazer adjusts her sunglasses, both radiating effortless confidence. The lighting is soft, golden-hour light, with a shallow depth of field blurring the background, creating a sense of movement and spontaneity. Shot with a 35mm prime lens, hyper-detailed, photorealistic, fashion magazine cover quality.",
"reference_images": [
"33",
0
],
"resolution": "1K",
"seed": 0,
"series_amount": "disabled"
},
"_meta": {
"title": "Kling 3.0 Omni Image"
}
},
"31": {
"class_type": "LoadImage",
"inputs": {
"image": "vintage_portrait.png"
},
"_meta": {
"title": "Load Image"
}
},
"32": {
"class_type": "LoadImage",
"inputs": {
"image": "Urban_Fashion.png"
},
"_meta": {
"title": "Load Image"
}
},
"33": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"31",
0
],
"images.image1": [
"32",
0
]
},
"_meta": {
"title": "Batch Images"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)