Generate Text to Video

Overview

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

Example

Ensure you replace "my_key" with your actual API key before running the code.

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