# 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": "UPLOADED_image_FILENAME"
},
"_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
],
"image_back": [
"9",
0
],
"image_left": [
"7",
0
],
"image_right": [
"8",
0
],
"seed": 42
},
"_meta": {
"title": "Hunyuan3D 3.6: Image(s) to Model"
}
},
"4": {
"class_type": "SaveGLB",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_multiview_to_model",
"mesh": [
"3",
0
]
},
"_meta": {
"title": "Save 3D Model"
}
},
"5": {
"class_type": "SaveGLB",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_multiview_to_model",
"mesh": [
"3",
1
]
},
"_meta": {
"title": "Save 3D Model"
}
},
"7": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_left_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"8": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_right_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"9": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_back_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"10": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_mv2m_roughness",
"images": [
"3",
5
]
},
"_meta": {
"title": "Save Image"
}
},
"11": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_mv2m_normal",
"images": [
"3",
4
]
},
"_meta": {
"title": "Save Image"
}
},
"12": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_mv2m_texture",
"images": [
"3",
2
]
},
"_meta": {
"title": "Save Image"
}
},
"13": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "3d/hunyuan3d_3_6_mv2m_metallic",
"images": [
"3",
3
]
},
"_meta": {
"title": "Save Image"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("2", "image", client.assets.from_url("https://example.com/replace-with-a-url/image"))
workflow.set_input("9", "image", client.assets.from_url("https://example.com/replace-with-a-url/image_back"))
workflow.set_input("7", "image", client.assets.from_url("https://example.com/replace-with-a-url/image_left"))
workflow.set_input("8", "image", client.assets.from_url("https://example.com/replace-with-a-url/image_right"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)