# 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({
"3": {
"class_type": "GeminiVideoOmniV2",
"inputs": {
"model": "Omni Flash 1.2",
"model.aspect_ratio": "16:9",
"model.images.image_1": [
"11",
0
],
"model.prompt": "Use @Image1 as the first frame. Keep the cyan-tinted young woman (knit beanie, denim jacket), the orange rounded-square panel, pink cartoon lightning bolts, and the bright blue collage field. Youthful indie-animator title-sequence energy — hand-made graphic motion, playful and stylish — not dark, not horror. The ringed planet stays a tiny background sticker only; never cut to a planet-only insert.\n\nSHOT ONE (0–1.5s), poster wide: collage elements wake up — pink bolts jitter then stretch longer, orange panel does a soft squash-and-stretch pulse, blue field gets a subtle grain shimmer; she starts a snappy in-place quarter-turn as the camera arcs left→front with a micro Dutch tilt. HARD CUT.\n\nSHOT TWO (1.5–3.2s), fashion medium: she continues the turn (feet planted), beanie bobbles, denim catches a light sweep; lightning bolts orbit her shoulders like stickers peeling and re-sticking; camera punches in then pulls a half-step with a playful whip. Identity locked to @Image1. HARD CUT.\n\nSHOT THREE (3.2–5s), hero close-medium: she faces lens, chin pops up, micro-smile; both bolts flash in sync then settle as bold graphic accents; orange panel does one final pop-scale; hold on HER — no cutaway plates.\n\nAudio: lo-fi indie synth ticks, paper/sticker rustle whooshes, sparkle hits on lightning, soft chime on final pop. No dialogue, no lyrics, no text overlays, no black frames.",
"model.resolution": "720p",
"model.seed": 95139821,
"model.task_type": "image_to_video"
},
"_meta": {
"title": "Google Gemini Omni (Video)"
}
},
"4": {
"class_type": "SaveVideo",
"inputs": {
"codec": "auto",
"filename_prefix": "video/Omni_Flash_1.2_i2v",
"format": "auto",
"format.codec": "auto",
"video": [
"3",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"11": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
}
})
workflow.set_input("11", "image", client.assets.from_url("https://comfy.org/catalog-media/fd571230-695f-411e-b3cf-dd8ba79d0537/3693c6a0-0948-420a-a42e-2e91bda0a2d7"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("4"):
output.to_file(output.name)