Skip to content
Dashboard

Kling v2.6 Motion Control

Kling v2.6 Motion Control transfers full-body motion from a 3-30 second reference clip to a generated scene, capturing gestures, facial expressions, lip-sync, and camera movement with frame-accurate fidelity. Your use is subject to Kling AI's Terms & Privacy Policies.

motion-control
import { experimental_generateVideo as generateVideo } from 'ai';
const result = await generateVideo({
model: 'klingai/kling-v2.6-motion-control',
prompt: 'A serene mountain lake at sunrise.'
});
Read docs

Getting started

Generate videos with Kling v2.6 Motion Control using the experimental_generateVideo function from AI SDK 6 or later. AI Gateway handles routing and polls until the video is ready.

Install the AI SDK (pnpm add ai dotenv), create an API key from the API Keys page, and set it as AI_GATEWAY_API_KEY in your environment. Full setup is covered in the video generation quickstart.

index.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
async function main() {
const result = await generateVideo({
model: 'klingai/kling-v2.6-motion-control',
prompt: {
image: fs.readFileSync('./character.png'),
},
providerOptions: {
klingai: {
videoUrl: 'https://example.com/dance-reference.mp4',
characterOrientation: 'video',
mode: 'std',
},
},
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);

Top-level parameters

Exercise the supported top-level parameters: prompt.image, prompt.text, aspectRatio, resolution, and duration.

top-level-params.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
async function main() {
const result = await generateVideo({
model: 'klingai/kling-v2.6-motion-control',
prompt: {
image: fs.readFileSync('./character.png'),
text: 'The character walks forward through a serene mountain landscape',
},
aspectRatio: '16:9',
resolution: '720p',
duration: 5,
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);
ParameterTypeRequiredDescription
prompt.imagestringYesURL of the image to animate.
prompt.textstringNoDescription of the motion or animation. Max 2500 characters.
durationnumberNoVideo length in seconds. 3-30 seconds.
resolutionstringNoResolution ('1280x720', '1920x1080').
aspectRatiostringNoAspect ratio ('16:9', '9:16', '1:1').

Input limits

InputFormatsSourcesMax countMax sizeLimits
TextUp to 2500 characters
Imagejpg, jpeg, pngurl, base64, buffer110 MB≥300px · aspect 2:5–5:2
Videomp4, movurl1100 MB3-30s · ≥340px · ≤3850px

Provider options

Load the required KlingAI motion-control options under providerOptions.klingai: videoUrl, characterOrientation, and mode.

provider-options.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
async function main() {
const result = await generateVideo({
model: 'klingai/kling-v2.6-motion-control',
prompt: {
image: fs.readFileSync('./character.png'),
text: 'The character performs the motion from the reference clip',
},
providerOptions: {
klingai: {
videoUrl: 'https://example.com/dance-reference.mp4',
characterOrientation: 'video',
mode: 'pro',
keepOriginalSound: 'yes',
watermarkEnabled: true,
pollIntervalMs: 5000,
pollTimeoutMs: 600000,
},
},
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);

Pass KlingAI-specific options under providerOptions.klingai in your generateVideo call.

ParameterTypeRequiredDescription
videoUrlstringYesURL of the reference motion video — see the Input limits table for supported formats, size, and dimensions. Max duration depends on characterOrientation.
characterOrientation'image' | 'video'Yes'image' matches the character image orientation (max 10s output). 'video' matches the reference video orientation (max 30s output).
mode'std' | 'pro'Yes'std' for standard quality. 'pro' for professional quality.
keepOriginalSound'yes' | 'no'NoKeep audio from the reference video. Defaults to 'yes'.
watermarkEnabledbooleanNoGenerate a watermarked result alongside the video.
pollIntervalMsnumberNoHow often to check task status. Defaults to 5000.
pollTimeoutMsnumberNoMaximum wait time. Defaults to 600000 (10 minutes).

Reference video and orientation

Motion control requires a reference clip via providerOptions.klingai.videoUrl. Provide the character as prompt.image and set characterOrientation to control how output duration is capped.

characterOrientation: 'image' limits output to 10 seconds and matches the character image orientation. 'video' limits output to 30 seconds and matches the reference video orientation.

The reference video must be a URL (use Vercel Blob for local files). Minimum 3 seconds of usable continuous motion is required.

Base64 image encoding

When passing an image as base64 (for example prompt.image), submit only the raw base64 string. Do not include a data:image/png;base64, prefix.

Motion transfer with Vercel Blob

Drive the character image with motion from a reference video. Upload local clips to Vercel Blob first, then pass the URL as videoUrl.

motion-transfer.ts
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'node:fs';
import 'dotenv/config';
import { put } from '@vercel/blob';
async function main() {
const referenceVideo = fs.readFileSync('./dance.mp4');
const { url: videoUrl } = await put('dance.mp4', referenceVideo, {
access: 'public',
});
const result = await generateVideo({
model: 'klingai/kling-v2.6-motion-control',
prompt: {
image: fs.readFileSync('./character.png'),
},
providerOptions: {
klingai: {
videoUrl,
characterOrientation: 'video',
mode: 'pro',
},
},
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);