DocsGuidesGenerating Videos

Generating Videos from Images

Learn how to transform static images into dynamic videos using Synexa AI’s powerful video generation API.

Basic Usage

Our API provides a straightforward way to generate videos from images using state-of-the-art models.

Python Example

import synexa
 
# Generate a video from an image
output = synexa.run(
    "tencent/hunyuan-video",
    input={
        "prompt": "A stylish woman walks down a Tokyo street"
    }
)
 
# Save the generated video
with open('output.mp4', 'wb') as f:
    f.write(output[0].read())

Node.js Example

import Synexa from 'synexa';
import fs from 'fs';
 
const synexa = new Synexa({
  auth: process.env.SYNEXA_API_TOKEN
});
 
// Generate a video from a text prompt
const [output] = await synexa.run("tencent/hunyuan-video", {
  input: {
    prompt: "A stylish woman walks down a Tokyo street"
  }
});
 
// Get the video URL or download it
if (output instanceof FileOutput) {
  const videoUrl = output.url();
  const videoData = await output.blob();
}

Advanced Options

You can customize the video generation with additional parameters:

# Python example with advanced options
output = synexa.run(
    "tencent/hunyuan-video",
    input={
        "prompt": "A cat walks on the grass, realistic style",
        "fps": 24,
        "width": 864,
        "height": 480,
        "infer_steps": 50,
        "video_length": 129,
        "embedded_guidance_scale": 6
    }
)
// Node.js example with advanced options
const [output] = await synexa.run("tencent/hunyuan-video", {
  input: {
    prompt: "A cat walks on the grass, realistic style",
    fps: 24,
    width: 864,
    height: 480,
    infer_steps: 50,
    video_length: 129,
    embedded_guidance_scale: 6
  }
});

Error Handling

Always handle potential errors when generating videos:

# Python error handling
try:
    output = synexa.run(
        "tencent/hunyuan-video",
        input={
            "prompt": "A stylish woman walks down a Tokyo street"
        }
    )
except Exception as e:
    print(f"Error generating video: {e}")
// Node.js error handling
try {
  const [output] = await synexa.run("tencent/hunyuan-video", {
    input: {
      prompt: "A stylish woman walks down a Tokyo street"
    }
  });
} catch (error) {
  console.error("Error generating video:", error);
}