# 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({
"4": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"12",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"9": {
"class_type": "CreateBoundingBoxes",
"inputs": {
"editor_state": {
"__value__": []
},
"height": 1024,
"last_incoming": {
"__value__": [
{
"height": 124,
"metadata": {
"desc": "Large elegant white display serif title at the top center of the cover. Decorative swash flourishes extend from the letters. Bold upright letterforms with high contrast against the dark background.",
"palette": [
"#ffffff"
],
"text": "Ideogram P-Image",
"type": "text"
},
"width": 824,
"x": 128,
"y": 32
},
{
"height": 928,
"metadata": {
"desc": "Figure in theatrical Renaissance-inspired high-fashion costume, waist-up. Smooth matte white porcelain mask with small dark circular eye holes and neutral melancholy expression. Antique-gold sculpted floral crown headpiece with off-white draped veil flowing over the shoulders. Dark black textured bodice with intricate gold embroidery and a large gold tassel pendant at the chest center. Extremely voluminous deep red silk ruffled sleeves. One gloved hand raised near the face in a delicate theatrical gesture.",
"palette": [
"#ffffff",
"#8b0000",
"#c9a227",
"#1a1a1a"
],
"text": "",
"type": "obj"
},
"width": 992,
"x": 32,
"y": 96
},
{
"height": 300,
"metadata": {
"desc": "Small white sans-serif side label stacked vertically along the left margin. Section header in medium weight with a short editorial quote beneath in lighter weight, left-aligned.",
"palette": [
"#ffffff"
],
"text": "CUSTOM\nNODES\n\"Extend what\nyou can build.\"",
"type": "text"
},
"width": 88,
"x": 22,
"y": 300
},
{
"height": 300,
"metadata": {
"desc": "Small white sans-serif side label stacked vertically along the right margin. Section header in medium weight with a short editorial quote beneath in lighter weight, right-aligned.",
"palette": [
"#ffffff"
],
"text": "WORKFLOW\n\"Drag. Connect.\nGenerate.\"",
"type": "text"
},
"width": 88,
"x": 914,
"y": 300
},
{
"height": 192,
"metadata": {
"desc": "Wide white sans-serif editorial quote in all capitals spanning the bottom of the cover. Medium weight, centered, with generous letter-spacing across two lines.",
"palette": [
"#ffffff"
],
"text": "CONNECT NODES. BUILD WORLDS. COMFYUI MAKES IT FLOW.",
"type": "text"
},
"width": 928,
"x": 64,
"y": 800
}
]
},
"width": 1024
},
"_meta": {
"title": "Create Bounding Boxes"
}
},
"11": {
"class_type": "IdeogramPImage",
"inputs": {
"aspect_ratio": "1:1",
"prompt": [
"4",
0
],
"prompt_upsampling": "AUTO",
"quality": "MEDIUM",
"resolution": "1K",
"seed": 1290088285
},
"_meta": {
"title": "Ideogram & Pruna P-Image"
}
},
"12": {
"class_type": "BuildJsonPromptIdeogram",
"inputs": {
"aesthetics": "High-fashion avant-garde editorial aesthetic with dramatic contrast and ornate costume details.",
"background": "dark",
"color_palette": {
"__value__": []
},
"element": [
"9",
2
],
"high_level_description": "An avant-garde high-fashion magazine cover titled 'Ideogram P-Image' featuring a masked figure in ornate Renaissance-inspired costume with voluminous red silk sleeves against a dark navy backdrop with subtle concentric graphic lines.",
"lighting": "Dramatic directional chiaroscuro lighting highlighting red silk and gold embroidery with deep shadows across the backdrop.",
"medium": "",
"style": "photo",
"style.photo": "editorial"
},
"_meta": {
"title": "Build JSON Prompt (Ideogram)"
}
},
"13": {
"class_type": "SaveImageAdvanced",
"inputs": {
"filename_prefix": "Ideogram_P-Image",
"format": "png",
"format.bit_depth": "8-bit",
"format.input_color_space": "sRGB",
"images": [
"11",
0
]
},
"_meta": {
"title": "Save Image (Advanced)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)