# 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({
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 4,
"denoise": 1,
"latent_image": [
"66",
0
],
"model": [
"70",
0
],
"negative": [
"65",
1
],
"positive": [
"78",
0
],
"sampler_name": "euler",
"scheduler": "normal",
"seed": 528364197559477,
"steps": 20
},
"_meta": {
"title": "KSampler"
}
},
"51": {
"class_type": "CLIPVisionEncode",
"inputs": {
"clip_vision": [
"54",
1
],
"crop": "none",
"image": [
"56",
0
]
},
"_meta": {
"title": "CLIP Vision Encode"
}
},
"54": {
"class_type": "ImageOnlyCheckpointLoader",
"inputs": {
"ckpt_name": "hunyuan3d-dit-v2-mv-turbo_fp16.safetensors"
},
"_meta": {
"title": "Load Checkpoint Image Only (img2vid model)"
}
},
"56": {
"class_type": "LoadImage",
"inputs": {
"image": "3d_hunyuan3d_multiview_to_model_turbo_front_view.png"
},
"_meta": {
"title": "Load Image"
}
},
"61": {
"class_type": "VAEDecodeHunyuan3D",
"inputs": {
"num_chunks": 8000,
"octree_resolution": 256,
"samples": [
"3",
0
],
"vae": [
"54",
2
]
},
"_meta": {
"title": "Hunyuan 3D VAE Decode"
}
},
"65": {
"class_type": "Hunyuan3Dv2ConditioningMultiView",
"inputs": {
"back": [
"81",
0
],
"front": [
"51",
0
],
"left": [
"54",
1
],
"right": [
"54",
1
]
},
"_meta": {
"title": "Hunyuan3Dv2ConditioningMultiView"
}
},
"66": {
"class_type": "EmptyLatentHunyuan3Dv2",
"inputs": {
"batch_size": 1,
"resolution": 3072
},
"_meta": {
"title": "Empty Hunyuan 3D v2 Latent"
}
},
"67": {
"class_type": "SaveGLB",
"inputs": {
"filename_prefix": "mesh/ComfyUI",
"mesh": [
"83",
0
]
},
"_meta": {
"title": "Save 3D Model"
}
},
"70": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"54",
0
],
"sampling": "flow",
"shift": 1.0000000000000002
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"78": {
"class_type": "FluxGuidance",
"inputs": {
"conditioning": [
"65",
0
],
"guidance": 3.5
},
"_meta": {
"title": "FluxGuidance"
}
},
"81": {
"class_type": "CLIPVisionEncode",
"inputs": {
"clip_vision": [
"54",
1
],
"crop": "none",
"image": [
"82",
0
]
},
"_meta": {
"title": "CLIP Vision Encode"
}
},
"82": {
"class_type": "LoadImage",
"inputs": {
"image": "3d_hunyuan3d_multiview_to_model_turbo_back_view.png"
},
"_meta": {
"title": "Load Image"
}
},
"83": {
"class_type": "VoxelToMesh",
"inputs": {
"algorithm": "surface net",
"threshold": 0.6,
"voxel": [
"61",
0
]
},
"_meta": {
"title": "Voxel to Mesh"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)