Nodes/comfyui-aimlapi-custom-nodes/AI/ML API Video Keyframes (Kling / Veo / Runway)
ComfyUI Node

AI/ML API Video Keyframes (Kling / Veo / Runway)

Kling, Veo 3.1, or Runway Gen-4 in one node

By konradbjk·Created 7 months ago·Updated 7 months ago· 1
AI/ML API Video Keyframes (Kling / Veo / Runway)
  • first_image
  • last_image
  • video_url
  • generation_id
api_key
modelkling-ai/video-o1-image-to-video
promptSmooth cinematic camera push between both frames
first_image_url
last_image_url
duration8
aspect_ratio16:9
resolution1080p
seed-1
generate_audiofalse
poll_interval5
poll_timeout480

Some shots are about the motion between two fixed moments: a camera push, a character turning, a scene morphing from one state to another. This node handles exactly that - you hand it a start frame and an end frame, it produces the video that connects them. It's the pack's keyframe node, and it wraps three different closed video models behind one interface, which is honestly the most useful thing about it: Kling, Google Veo 3.1 (fast first/last), and Runway Gen-4 Turbo, all in a single dropdown.

Mechanically it shares the pack's video pipeline - POST to https://api.aimlapi.com/v2/video/generations, poll every poll_interval seconds up to poll_timeout (default 480s), surface failure states like canceled/expired, and emit video_url + generation_id. The detail worth knowing is in the code: the field name for the end frame isn't universal. Kling and Veo expect last_image_url, but Runway's API calls it tail_image_url - the node picks the right field per model, which is the kind of thing that would otherwise turn into a cryptic 400 error.

The inputs that matter. api_key, model, prompt (the high-level direction for the interpolation - "smooth cinematic camera push between both frames" is the sensible default), plus:

  • first_image / first_image_url - always required, your starting frame. Give a tensor (encoded to a data URI) or a direct HTTPS URL to skip encoding.
  • last_image / last_image_url - required for Veo first/last, optional for Kling and Runway (both of which happily animate from a single frame into motion).
  • duration (4–12s), aspect_ratio (sent to all three), resolution (only used by Veo - 720p or 1080p), seed (Runway only, -1 for random), and generate_audio (only Veo supports it here).

The output pairing is where this shines in a real workflow: video_url for playback or a downloader node, and generation_id so you can reconcile a failed or lost job against AI/ML API's dashboard.

Installing it. Same as every node in this pack: ComfyUI Manager search comfyui-aimlapi-custom-nodes, or

cd ComfyUI/custom_nodes
git clone https://github.com/konradbjk/comfyui-aimlapi-custom-nodes

Restart, look under "AI/ML API". The deps are just requests, pillow, and numpy; no models to download, and the actual generation happens on AI/ML API's servers for per-job billing. Key goes in the masked api_key widget from https://aimlapi.com/app/keys.

What usually bites people. The number one stumble is forgetting the second frame on Veo - the node throws a clear "Last image is required" error, but only because the code explicitly validates it. Also know what you're paying for: all three of these are closed commercial models, and Kling and Runway sit at the premium end of video pricing, so an 12-second keyframe interpolation is not a free experiment. And as with the other video nodes, this one blocks your ComfyUI queue while polling - if your job is slow, raise poll_timeout rather than assuming it's hung.

CategoryAI/ML API

Inputs (14)

NameTypeDefaultDescription
api_keySTRINGYour AI/ML API key from https://aimlapi.com/app/keys
modelCOMBOkling-ai/video-o1-image-to-videoSelect which keyframe-aware model to run
promptSTRINGSmooth cinematic camera push between both framesHigh-level direction for the interpolation
first_imageoptIMAGEStarting frame tensor
first_image_urloptSTRINGHTTPS link or data URI if no tensor is provided
last_imageoptIMAGEEnding frame tensor
last_image_urloptSTRINGHTTPS link or data URI for the ending frame
durationoptINT84–12Video duration (seconds)
aspect_ratiooptCOMBO16:9Framing passed to models that support it
resolutionoptCOMBO1080pOnly used by Google Veo first/last
seedoptINT-1-1–999999999Seed (Runway Gen-4 Turbo only, -1 for random)
generate_audiooptBOOLEANfalseToggle audio generation if the model supports it
poll_intervaloptFLOAT51–30Seconds between status checks
poll_timeoutoptINT48060–1800Maximum seconds to wait before timing out

Outputs (2)

NameTypeDescription
video_urlSTRING
generation_idSTRING