# 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({
"2": {
"class_type": "LoadImage",
"inputs": {
"image": "api_hunyuan3d_3_6_image_to_model_input.png"
},
"_meta": {
"title": "Load Image"
}
},
"3": {
"class_type": "TencentHunyuan3D36ImageToModelNode",
"inputs": {
"face_count": 500000,
"generate_type": "Normal",
"generate_type.bake_lighting": False,
"generate_type.pbr": False,
"generate_type.texture_resolution": "2k",
"image": [
"2",
0
],
"seed": 42
},
"_meta": {
"title": "Hy3D 3.6: Image(s) to Model"
}
},
"4": {
"class_type": "SaveGLB",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_image_to_model",
"mesh": [
"3",
0
]
},
"_meta": {
"title": "Save 3D Model"
}
},
"5": {
"class_type": "SaveGLB",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_image_to_model",
"mesh": [
"3",
1
]
},
"_meta": {
"title": "Save 3D Model"
}
},
"6": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_i2m_texture",
"images": [
"3",
2
]
},
"_meta": {
"title": "Save Image"
}
},
"7": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_i2m_metallic",
"images": [
"3",
3
]
},
"_meta": {
"title": "Save Image"
}
},
"8": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_i2m_roughness",
"images": [
"3",
3
]
},
"_meta": {
"title": "Save Image"
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_i2m_normal",
"images": [
"3",
4
]
},
"_meta": {
"title": "Save Image"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)