This guide explains how to use the Runway AI video generation feature that has been integrated into the AI Content Processing system.
The Runway integration allows you to generate videos from static images using AI. It uses Runway's Gen-4 Turbo model to create short videos with smooth motion and cinematic quality.
You need a Runway API key to use this feature:
- Sign up at runwayml.com
- Get your API key from the Runway dashboard
- Add it to your
.envfile:
RUNWAY_API_KEY=your_runway_api_key_hereMake sure the Runway SDK is installed:
pip install runwayml>=0.16.0Or install from the updated requirements.txt:
pip install -r requirements.txtpython run_api.py
# or
uvicorn api_server:app --host 0.0.0.0 --port 8000 --reloadcurl -X POST "http://localhost:8000/generate-video" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://example.com/your-image.jpg",
"prompt_text": "A serene mountain landscape with clouds slowly drifting",
"ratio": "1280:720",
"duration": 5
}'import requests
response = requests.post("http://localhost:8000/generate-video", json={
"image_url": "https://example.com/image.jpg",
"prompt_text": "Beautiful ocean waves with seabirds flying",
"ratio": "1280:720",
"duration": 8,
"model": "gen4_turbo"
})
result = response.json()
print(f"Video URL: {result['video_url']}")Use the provided CLI script:
# Basic usage
python runway_video_cli.py --image "https://example.com/image.jpg"
# Custom prompt and settings
python runway_video_cli.py \
--image "https://example.com/mountain.jpg" \
--prompt "Clouds slowly drifting across mountain peaks" \
--duration 8 \
--ratio "1024:1024" \
--output "mountain_video.json"from src.text_extractor import TextExtractor
# Initialize extractor
extractor = TextExtractor()
# Generate video
result_json = extractor.generate_video_from_image(
image_path="https://example.com/image.jpg",
prompt_text="A peaceful forest scene with gentle wind",
ratio="1280:720",
duration=5
)
import json
result = json.loads(result_json)
print(f"Status: {result['status']}")
if result['status'] == 'success':
print(f"Video URL: {result['video_url']}")- image_url (string): URL of the source image
- Must be a publicly accessible image URL
- Supported formats: JPG, PNG, GIF, BMP, TIFF, WEBP
-
prompt_text (string): Text describing the desired video content
- Default: "A cinematic video with smooth motion"
- Examples: "Gentle waves on a beach", "Clouds moving across the sky"
-
ratio (string): Video aspect ratio
- Default: "1280:720" (16:9)
- Options: "1280:720", "1024:1024", "720:1280", etc.
-
duration (integer): Video length in seconds
- Default: 5
- Range: 1-10 seconds
-
model (string): Runway model to use
- Default: "gen4_turbo"
- Available: "gen4_turbo" (currently the main model)
The API returns a JSON response with the following structure:
{
"request_id": "uuid-string",
"status": "success|failed|timeout|error",
"task_id": "runway-task-id",
"video_url": "https://runway-generated-video.mp4",
"source_image": "https://your-source-image.jpg",
"prompt_text": "Your prompt text",
"ratio": "1280:720",
"duration": 5,
"model": "gen4_turbo",
"processing_time_seconds": 45.2,
"error": null,
"timestamp": "2025-09-26T10:30:00Z"
}- success: Video generated successfully,
video_urlcontains the result - failed: Generation failed, check
errorfield for details - timeout: Generation took too long (>5 minutes), may still be processing
- error: System error occurred, check
errorfield
curl -X POST "http://localhost:8000/generate-video" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://images.unsplash.com/photo-1506905925346-21bda4d32df4",
"prompt_text": "Majestic mountain peaks with clouds slowly drifting across the sky",
"ratio": "1280:720",
"duration": 8
}'curl -X POST "http://localhost:8000/generate-video" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://images.unsplash.com/photo-1439066615861-d1af74d74000",
"prompt_text": "Gentle ocean waves with seabirds flying overhead",
"ratio": "1280:720",
"duration": 6
}'curl -X POST "http://localhost:8000/generate-video" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://images.unsplash.com/photo-1441974231531-c6227db76b6e",
"prompt_text": "Peaceful forest with leaves gently swaying in the breeze",
"ratio": "1024:1024",
"duration": 5
}'Run the example script to test the integration:
python runway_video_examples.pyThis script will:
- Check API health
- Test video generation via API endpoint
- Test direct processor usage
- Generate CURL examples
- Save results to JSON files
-
"Runway processor not available"
- Check that
RUNWAY_API_KEYis set in your.envfile - Verify the key is valid and active
- Check that
-
"Import error: No module named 'runwayml'"
- Install the Runway SDK:
pip install runwayml>=0.16.0
- Install the Runway SDK:
-
"Video generation timed out"
- Video generation can take 1-5 minutes depending on complexity
- The video might still be processing on Runway's servers
- Check the task ID in Runway's dashboard
-
"Failed to fetch asset" or "Image URL not accessible"
- Ensure the image URL is publicly accessible
- Try the URL in a browser to verify it works
- Use direct image URLs without complex query parameters
- For Unsplash images, use format:
https://images.unsplash.com/photo-ID?w=800&q=80 - Avoid URLs with
auto=format,dpr=, orixlib=parameters - Some CDNs block external access - try downloading and hosting elsewhere
- Runway has usage limits based on your subscription plan
- The system includes automatic retry logic for temporary failures
- Monitor your Runway dashboard for usage statistics
The Runway integration consists of:
src/file_processors/runway_processor.py- Main processor classsrc/config.py- Configuration (API key, model settings)api_server.py- FastAPI endpoint/generate-videorunway_video_cli.py- Command-line interfacerunway_video_examples.py- Testing and examples
The Runway processor follows the same pattern as other processors in the system:
- Inherits from
BaseProcessor - Implements
can_process()andextract_text()methods - Integrates with the
TextExtractororchestrator - Provides both direct usage and API endpoints
- Video generation typically takes 30 seconds to 3 minutes
- Processing time depends on video complexity and Runway server load
- The system includes a 5-minute timeout with polling every 10 seconds
- Results are returned as soon as generation completes
The video generation endpoint is automatically included in the FastAPI documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Look for the /generate-video endpoint in the documentation for interactive testing.
- Use descriptive prompts: Better prompts lead to better videos
- Choose appropriate ratios: Match your intended use case (social media, web, etc.)
- Start with shorter durations: 3-5 seconds often work best
- Use high-quality source images: Better input leads to better output
- Monitor processing time: Video generation is resource-intensive
For issues specific to this integration:
- Check the logs for detailed error messages
- Verify your Runway API key and quota
- Test with the provided examples first
For Runway-specific issues:
- Check Runway's documentation: https://docs.dev.runwayml.com/
- Monitor your Runway dashboard for usage and limits