Batch-transfer motion from a reference video onto a static image through the Kling API by useapi.net — the person in your image performs the action from the video.
📖 Full walkthrough: Kling Lip-Sync Avatars, Motion Control & Image Generation
kling-motion.mjs reads prompts from prompts.json, submits each one to POST /videos/motion-create, polls GET /tasks/{task_id} until each task is final, and downloads every finished MP4 — preferring the clean, non-watermarked master via GET /assets/download.
- Node.js v21 or newer (no dependencies to install — uses built-in
fetch) - A useapi.net API token
- A connected Kling account email
node ./kling-motion.mjs <API_TOKEN> <EMAIL> [PROMPTS_FILE]PROMPTS_FILE defaults to prompts.json. The script looks the account up by email before submitting.
Each prompt needs an imageUrl (a person with a clearly visible pose) and a motionUrl (a 3–30 second reference video). Upload both via POST /assets first — use the response url field for imageUrl and the resourceUrl field for motionUrl (or pull an official/previous motion from GET /videos/motions).
model_name defaults to kling-v3-0 (or kling-v2-6); the output duration is detected from the motion video. Optional: prompt, keepAudio (keep the reference video's sound), motionDirection (motion_direction default, or image_direction), mode, and on v3 an element_1 for stronger character consistency. The endpoint returns a 400 with MOTION.PIC_NOT_MATCHED if it can't detect a person in the image. The placeholder asset URLs in prompts.json are examples — replace them with your own. Every parameter is documented on POST /videos/motion-create.