# 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": "OpenAIGPTImageGIFNode",
"inputs": {
"model": "gpt-image-2.6-flare",
"model.background": "opaque",
"model.complexity": "high",
"model.frame_count": 9,
"model.frame_duration_ms": 200,
"model.prompt": "1990s streetwear sticker illustration, flat vector look, not photographic: a bust of a kid whose head is an old cream CRT monitor with one big blue eye on the screen, a tiny alien charm hanging from an ear, spiked red wristband, denim vest over a pink tee. Heavy black linework with cross-hatching and halftone dots, flat mauve, hot pink, lime and sky blue fills, a thick white keyline around every shape, flat pale grey ground, thick rounded poster frame. Loop: the eye on the screen blinks, the monitor cable sways, the body stays still. Dense but readable graphic poster, no text, no lettering, no brand logos",
"model.quality": "medium",
"model.seed": 42,
"model.size": "512x512"
},
"_meta": {
"title": "OpenAI GPT Image 2.6 GIF"
}
},
"2": {
"class_type": "SaveAnimatedWEBP",
"inputs": {
"filename_prefix": "api_openai_gpt_image_26_flare_gif",
"fps": [
"1",
1
],
"images": [
"1",
0
],
"lossless": True,
"method": "default",
"quality": 90
},
"_meta": {
"title": "Save Animated WEBP"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)