Generate Image to Video

Overview

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

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/image-to-video',
      prompt: 'Mona Lisa puts on glasses with her hands.',
      ratio: '16:9',
      image_url: 'https://s2-111386.kwimgs.com/bs2/mmu-aiplatform-temp/kling/20240620/1.jpeg',
      duration: '5',
    }),
  }).then((res) => res.json());

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

main()

Last updated