# 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": "IdeogramTextToImageApi",
"inputs": {
"model": "ideogram-4.6",
"model.background": "opaque",
"model.height": 2048,
"model.magic_prompt": "off",
"model.prompt": "Playful children's fashion magazine cover, bright happy storybook mood. Sky-blue backdrop with a lush green grass field in front. A giant fluffy apricot-and-cream CAT sits behind a young model, huge round amber eyes, tiny pink nose, thick soft fur, wearing a daisy chain collar with a little red bow, one big paw resting in the grass, tail curled up, friendly and silly. The model is a young woman with short curly ginger hair and freckles, wearing oversized butter-yellow and sky-blue patchwork quilted overalls over a striped tee, red rain boots with white toes, and a crocheted bucket hat with tiny mushroom charms; she leans back on one leg, laughing, one hand holding a red balloon on a string. Storybook props around them: giant white mushrooms with big yellow polka dots, enormous white daisies with orange centres, chunky blue pompom flowers, a tall green cactus with red flowers on the left, purple bellflowers on the right, little red poppies, a few floating soap bubbles, and a small orange snail on a leaf. Bright even daylight, juicy saturated colour, printed paper grain, hand-made collage feel. Typography: giant cream didone serif masthead reading 'IDEOGRAM' across the very top, letters bleeding off the top and both side edges. Tiny cream caps under it on the left: 'NOVEMBER 2026 VOL 4.6'. Left side serif italic cream cover line: 'Silly Little Prompts', with small caps under it 'TEXT TO IMAGE'. Right side small cream caps stacked: 'NATIVE 4K' then 'PRECISE EDITS'. Bottom edge centred serif italic cream: 'Say it out loud. Watch it appear.' Bottom left a small barcode. Clean legible typography, no overlapping letters, no real world brand logos or trademarks, no watermark.",
"model.quality": "medium",
"model.seed": 1722585897,
"model.size": "(2K) 2048x2048 (1:1)",
"model.width": 2048
},
"_meta": {
"title": "Ideogram Text to Image"
}
},
"2": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "api_ideogram_v4_6_t2i",
"images": [
"1",
0
]
},
"_meta": {
"title": "Save Image"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)