# 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({
"28": {
"class_type": "RecraftCreateStyleNode",
"inputs": {
"images.image0": [
"29",
0
],
"images.image1": [
"36",
0
],
"images.image2": [
"38",
0
],
"images.image3": [
"39",
0
],
"style": "realistic_image"
},
"_meta": {
"title": "Recraft Create Style"
}
},
"29": {
"class_type": "LoadImage",
"inputs": {
"image": "recraft_style_ref-1.png"
},
"_meta": {
"title": "Load Image"
}
},
"33": {
"class_type": "RecraftStyleV3InfiniteStyleLibrary",
"inputs": {
"style_id": [
"28",
0
]
},
"_meta": {
"title": "Recraft Style - Infinite Style Library"
}
},
"34": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Recraft-style",
"images": [
"53",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"36": {
"class_type": "LoadImage",
"inputs": {
"image": "recraft_style_ref-3.png"
},
"_meta": {
"title": "Load Image"
}
},
"38": {
"class_type": "LoadImage",
"inputs": {
"image": "recraft_style_ref-2.png"
},
"_meta": {
"title": "Load Image"
}
},
"39": {
"class_type": "LoadImage",
"inputs": {
"image": "recraft_style_ref-4.png"
},
"_meta": {
"title": "Load Image"
}
},
"48": {
"class_type": "RecraftStyleV3InfiniteStyleLibrary",
"inputs": {
"style_id": "COPY PASTE STYLE ID HERE AND CONNECT"
},
"_meta": {
"title": "Recraft Style - Infinite Style Library"
}
},
"49": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"33",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"53": {
"class_type": "RecraftTextToImageNode",
"inputs": {
"n": 1,
"negative_prompt": "",
"prompt": "A soft-focus, painterly vintage photograph of David's marble bust, surrounded by an abundant, lush tapestry of antique roses, lilacs, and forget-me-nots in muted blush and lavender tones. The background is entirely filled with flowers, with soft, diffused light creating a luminous, ethereal quality on the marble. The image features a warm sepia filter, delicate vignetting, and a romantic, timeless mood, 4K.",
"recraft_style": [
"33",
0
],
"seed": 0,
"size": "1024x1024"
},
"_meta": {
"title": "Recraft V3 Text to Image"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)