Generate Text to Video

Overview

You can generate a video using the AI/ML API. In the basic setup, you need only a prompt.

post

/v2/generate/video/kling/generation

Authorizations
Body
any of
Responses
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v2/generate/video/kling/generation' \
  --header 'Authorization: Bearer JWT' \
  --header 'Content-Type: application/json' \
  --data '{"prompt":"text","image_url":"https://example.com","last_image_url":"https://example.com","duration":"5","model":"runway-gen3/turbo/image-to-video","ratio":"16:9"}'

No body

Example

const main = async () => {
  const response = await fetch('https://api.aimlapi.com/v2/generate/video/kling/generation', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer my_key',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'kling-video/v1/standard/text-to-video',
      prompt: 'A DJ on the stand is playing, around a World War II battlefield, lots of explosions, thousands of dancing soldiers, between tanks shooting, barbed wire fences, lots of smoke and fire, black and white old video: hyper realistic, photorealistic, photography, super detailed, very sharp, on a very white background',
      ratio: '16:9',
      duration: '5',
    }),
  }).then((res) => res.json());

  console.log('Generation:', response);
};

Last updated

Was this helpful?