# 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({
"1": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"3",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"3": {
"class_type": "RecraftTextToImageNode",
"inputs": {
"n": 1,
"negative_prompt": "",
"prompt": "A young boy performing a dynamic skateboard trick in a sunlit skate park. He's wearing a white t-shirt and green shorts, captured mid-air with his blonde hair blowing in the wind. The skateboard is in motion as he rides a blue, curved ramp, creating a sense of energy and movement. The scene is painted in a bold, expressive oil painting style, with thick brushstrokes that enhance the vibrant and lively atmosphere. The background features a bright blue ramp, adding to the feeling of freedom and adventure.",
"recraft_controls": [
"10",
0
],
"recraft_style": [
"4",
0
],
"seed": 0,
"size": "1536x1024"
},
"_meta": {
"title": "Recraft V3 Text to Image"
}
},
"4": {
"class_type": "RecraftStyleV3DigitalIllustration",
"inputs": {
"substyle": "2d_art_poster"
},
"_meta": {
"title": "Recraft Style - Digital Illustration"
}
},
"8": {
"class_type": "RecraftColorRGB",
"inputs": {
"b": 208,
"g": 44,
"r": 241,
"recraft_color": [
"12",
0
]
},
"_meta": {
"title": "Recraft Color RGB"
}
},
"9": {
"class_type": "RecraftColorRGB",
"inputs": {
"b": 65,
"g": 255,
"r": 241,
"recraft_color": [
"8",
0
]
},
"_meta": {
"title": "Recraft Color RGB"
}
},
"10": {
"class_type": "RecraftControls",
"inputs": {
"background_color": [
"12",
0
],
"colors": [
"9",
0
]
},
"_meta": {
"title": "Recraft Controls"
}
},
"12": {
"class_type": "RecraftColorRGB",
"inputs": {
"b": 196,
"g": 44,
"r": 24
},
"_meta": {
"title": "Recraft Color RGB"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)