Overview
The Weights API provides video generation capabilities that can animate static images. You provide an input image and a prompt describing the desired motion, and the API creates a video that brings your image to life.Prerequisites
- A Weights API account with an API key
- An image file uploaded to a web-accessible URL
- Basic knowledge of HTTP requests and JSON
- The Weights SDK installed (optional but recommended)
Step 1: Set Up Your Environment
First, install the Weights SDK and set up your authentication:Step 2: Prepare Your Input Image
Before creating a video, you need to upload your image to a web-accessible location. The API requires a publicly accessible URL for the input image.Image Requirements
- Format: Common image formats (JPEG, PNG, WebP)
- Size: Recommended resolution for best results
- Accessibility: Must be accessible via HTTP/HTTPS URL
- Content: Clear, high-quality images work best
Example Image Upload
Step 3: Create Your First Video
Start by creating a video generation job:Request Parameters
- prompt (required): Description of the motion you want to apply to the image
- inputImageUrl (required): URL of the input image to animate
Step 4: Monitor Video Generation
Video generation is asynchronous and typically takes longer than image generation. Poll the status to track progress:Job Statuses
- QUEUED: Job is waiting in the processing queue
- PENDING_WORKER: Job is assigned to a worker
- PROCESSING: Video is being generated
- SUCCEEDED: Generation completed successfully
- ERRORED: Generation failed
- CANCELED: Job was canceled
Step 5: Retrieve Your Generated Video
Once the status isSUCCEEDED
, your video is ready for download:
Advanced Video Generation
Different Motion Types
Experiment with various motion prompts:Best Practices
Writing Effective Motion Prompts
- Be specific: “Gentle left-to-right swaying motion” vs “movement”
- Describe the type of motion: “swaying”, “spinning”, “floating”, “breathing”
- Include speed: “slow”, “fast”, “gentle”, “dramatic”
- Mention natural elements: “like wind”, “like water”, “like fire”
Image Selection Tips
- High quality: Use clear, high-resolution images
- Good composition: Images with clear subjects work better
- Appropriate content: Some image types animate better than others
- Avoid busy backgrounds: Simple backgrounds often produce better results
Error Handling
Complete Example
Here’s a complete example that creates a video and waits for completion:Use Cases
Content Creation
- Social Media: Create engaging animated content for platforms like Instagram, TikTok
- Marketing: Animate product images for promotional materials
- Art: Bring static artwork to life with motion
Creative Projects
- Portraits: Add subtle movement to portrait photography
- Landscapes: Animate nature scenes with wind or water effects
- Abstract Art: Create dynamic abstract animations
Performance Considerations
- Processing Time: Video generation typically takes 5-15 minutes
- Queue Position: Jobs are processed in order, so expect some wait time
- File Size: Generated videos are optimized for web delivery
- URL Expiration: Download URLs have limited availability
Next Steps
- Explore Image Generation to create source images
- Learn about LoRA Model Training for custom styles
- Check out Song Generation to add audio to your videos