# 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": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"4": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into 3d animation, maintain character and background identity",
"seed": 923725119
},
"_meta": {
"title": "Grok Image Edit"
}
},
"5": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-3d",
"images": [
"4",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"6": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into claymation, maintain character and background identity",
"seed": 626651379
},
"_meta": {
"title": "Grok Image Edit"
}
},
"7": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-claymation",
"images": [
"6",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"10": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into hyper realistic, maintain character and background identity",
"seed": 778259071
},
"_meta": {
"title": "Grok Image Edit"
}
},
"11": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-realistic",
"images": [
"10",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"12": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into cross stitch, maintain character and background identity",
"seed": 1315151478
},
"_meta": {
"title": "Grok Image Edit"
}
},
"13": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-cross_stitch",
"images": [
"12",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"14": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into oil painting with visible brushstrokes, maintain character and background identity",
"seed": 2089487176
},
"_meta": {
"title": "Grok Image Edit"
}
},
"15": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-oil_painting",
"images": [
"14",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"16": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into detailed colored pencil, maintain character and background identity",
"seed": 1783897462
},
"_meta": {
"title": "Grok Image Edit"
}
},
"17": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-colored_pencil",
"images": [
"16",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"18": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into flat vector illustration, maintain character and background identity",
"seed": 2035280383
},
"_meta": {
"title": "Grok Image Edit"
}
},
"19": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-vector",
"images": [
"18",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"20": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into reflective metal sculpture, maintain character and background identity",
"seed": 1158415507
},
"_meta": {
"title": "Grok Image Edit"
}
},
"21": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-metal",
"images": [
"20",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"22": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into charcoal sketch, maintain character and background identity",
"seed": 635577419
},
"_meta": {
"title": "Grok Image Edit"
}
},
"23": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-charcoal",
"images": [
"22",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"24": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into lineart, maintain character and background identity",
"seed": 280525599
},
"_meta": {
"title": "Grok Image Edit"
}
},
"25": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-lineart",
"images": [
"24",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"26": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into watercolor, maintain character and background identity",
"seed": 1050327575
},
"_meta": {
"title": "Grok Image Edit"
}
},
"27": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-watercolor",
"images": [
"26",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"45": {
"class_type": "GrokImageEditNodeV2",
"inputs": {
"model": "grok-imagine-image-quality",
"model.aspect_ratio": "auto",
"model.images.image_1": [
"1",
0
],
"model.number_of_images": 1,
"model.resolution": "1K",
"prompt": "Change the style into pixel art, maintain character and background identity",
"seed": 2140144728
},
"_meta": {
"title": "Grok Image Edit"
}
},
"46": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-pixel_art",
"images": [
"45",
0
]
},
"_meta": {
"title": "Save Image"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("1", "image", client.assets.from_url("https://example.com/replace-with-a-url/image"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)