# 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({
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Lotus_depth",
"images": [
"74:22",
0
]
},
"_meta": {
"title": "output"
}
},
"12": {
"class_type": "LoadImage",
"inputs": {
"image": "image_lotus_depth_v1_1_input_image.png"
},
"_meta": {
"title": "input"
}
},
"74:10": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "lotus-depth-d-v1-1.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"74:14": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "vae-ft-mse-840000-ema-pruned.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"74:16": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"74:19",
0
],
"latent_image": [
"74:23",
0
],
"noise": [
"74:18",
0
],
"sampler": [
"74:21",
0
],
"sigmas": [
"74:28",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"74:18": {
"class_type": "DisableNoise",
"inputs": {},
"_meta": {
"title": "DisableNoise"
}
},
"74:19": {
"class_type": "BasicGuider",
"inputs": {
"conditioning": [
"74:68",
0
],
"model": [
"74:10",
0
]
},
"_meta": {
"title": "Basic Guider"
}
},
"74:20": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"74:10",
0
],
"scheduler": "normal",
"steps": 1
},
"_meta": {
"title": "BasicScheduler"
}
},
"74:21": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"74:22": {
"class_type": "ImageInvert",
"inputs": {
"image": [
"74:8",
0
]
},
"_meta": {
"title": "Invert Image Colors"
}
},
"74:23": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"12",
0
],
"vae": [
"74:14",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"74:28": {
"class_type": "SetFirstSigma",
"inputs": {
"sigma": 999.0000000000002,
"sigmas": [
"74:20",
0
]
},
"_meta": {
"title": "SetFirstSigma"
}
},
"74:68": {
"class_type": "LotusConditioning",
"inputs": {},
"_meta": {
"title": "LotusConditioning"
}
},
"74:8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"74:16",
0
],
"vae": [
"74:14",
0
]
},
"_meta": {
"title": "VAE Decode"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)