Generate Video

Overview

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

post

/v2/generate/video/minimax/generation

Authorizations
Body
promptstringrequired

Description of the video

prompt_optimizerboolean

The model will automatically optimize the incoming prompt to improve the generation quality If necessary. For more precise control, this parameter can be set to False, and the model will follow the instructions more strictly. At this time It is recommended to provide finer prompts for best results.

first_frame_imagestring uri
    The model will use the image passed in this parameter as the first frame to generate a video. 
    Supported formats:
    - URL of the image
    - base64 encoding of the image
    Image specifications:
    - format must be JPG, JPEG, or PNG;
    - aspect ratio should be greater than 2:5 and less than 5:2; the shorter side must exceed 300 pixels
    - file size must not exceed 20MB.
modelenumrequired

Model id

Options: video-01, video-01-live2d
Responses
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v2/generate/video/minimax/generation' \
  --header 'Authorization: Bearer JWT' \
  --header 'Content-Type: application/json' \
  --data '{"prompt":"text","prompt_optimizer":true,"model":"video-01"}'
{
  "generation_id": "222226666699999"
}

Example: Create video based on first frame and prompt

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/minimax/generation', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer <YOUR_API_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'video-01',
      prompt: 'Mona Lisa puts on glasses with her hands.',
      first_frame_image: 'https://s2-111386.kwimgs.com/bs2/mmu-aiplatform-temp/kling/20240620/1.jpeg',
    }),
  }).then((res) => res.json());

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

main()

Last updated

Was this helpful?