How to Generate Videos using the sunra API

sunra offers a simple and easy-to-use API that allows you to generate videos from your images using pre-trained models. This endpoint is perfect for creating video clips from your images for various use cases such as social media, marketing, and more.

Here is an example of how to generate videos using the sunra API:

import { sunra } from "@sunra/client";

const result = await sunra.subscribe("kling/kling-v2-master/image-to-video", {
  input: {
    prompt: 'A cute hamster lies leisurely on a lifebuoy, wearing fashionable sunglasses, and drifts with the gentle waves on the shimmering sea surface. The hamster reclines comfortably, enjoying a peaceful and pleasant time. Cartoon style, the camera follows the subject moving, with a heartwarming and high picture quality.',
    negative_prompt: '',
    guidance_scale: 0.5,
    aspect_ratio: '16:9',
    duration: 5,
    start_image: 'https://assets.sunra.ai/uploads/1748811753168-05ceab0d.png'
  },
  logs: true,
  onQueueUpdate: (update) => {
    console.log(update)
  },
});
console.log(result.data);
console.log(result.requestId);

How to select the model to use

sunra offers a variety of video generation models. You can select the model that best fits your needs based on the style and quality of the videos you want to generate. Here are some of the available models:

To select a model, simply specify the model ID in the subscribe method as shown in the example above. You can find more models and their descriptions in the Image to Video Models page.