# 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": "Ovis_2.5",
"images": [
"57:43",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"57:39": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "ovis_2.5.safetensors",
"device": "default",
"type": "ovis"
},
"_meta": {
"title": "Load CLIP"
}
},
"57:40": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "ae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"57:41": {
"class_type": "EmptySD3LatentImage",
"inputs": {
"batch_size": 1,
"height": 1024,
"width": 1024
},
"_meta": {
"title": "EmptySD3LatentImage"
}
},
"57:43": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"57:44",
0
],
"vae": [
"57:40",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"57:44": {
"class_type": "KSampler",
"inputs": {
"cfg": 5,
"denoise": 1,
"latent_image": [
"57:41",
0
],
"model": [
"57:47",
0
],
"negative": [
"57:49",
0
],
"positive": [
"57:45",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 775709856082329,
"steps": 20
},
"_meta": {
"title": "KSampler"
}
},
"57:45": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"57:39",
0
],
"text": "Child lying on bed with balloons, streamers, and plush toys, surreal dreamlike scene. Close-up, centered on the child and surrounding objects. Soft, diffused lighting."
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"57:46": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "ovis_image_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"57:47": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"57:46",
0
],
"sampling": "flow",
"shift": 3
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"57:49": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"57:39",
0
],
"text": ""
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)