Video Generation
Generate videos with any model available on ImageRouter.
Text to Video
Section titled “Text to Video”curl 'https://api.imagerouter.io/v1/openai/videos/generations' \-H 'Authorization: Bearer YOUR_API_KEY' \--json '{ "prompt": "YOUR_PROMPT", "model": "ir/test-video", "size": "auto", "seconds": "auto"}'const url = 'https://api.imagerouter.io/v1/openai/videos/generations'const payload = { prompt: 'YOUR_PROMPT', model: 'ir/test-video', size: 'auto', seconds: 'auto'}
const response = await fetch(url, { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify(payload)})
const data = await response.json()console.log(data)import requests
url = "https://api.imagerouter.io/v1/openai/videos/generations"payload = { "prompt": "YOUR_PROMPT", "model": "ir/test-video", "size": "auto", "seconds": "auto"}headers = { "Authorization": "Bearer YOUR_API_KEY"}
response = requests.post(url, json=payload, headers=headers)print(response.json())Parameters
Section titled “Parameters”prompt* Text prompt for generating the video.model* Video model to use.size- Accepted values are different for each model.auto[default] - Uses the default recommended size for each model.WIDTHxHEIGHT(eg 1024x576)
seconds- Duration of the video in seconds. Accepted values vary by model.auto[default] - Uses a default duration for each model.- Numeric value (eg 5, 10) - Specific duration in seconds (check model details page for supported values).
response_formaturl[default] - Returns the video URL hosted on ImageRouter’s servers. The video is accessible in your logs. and is publicly accessible with the URL if you share it.b64_json- Returns the video as base64-encoded JSON data. The video is saved in your logs and is publicly accessible with the URL if you share it.b64_ephemeral- Same as b64_json but the video is not saved in our system. The provider may still have it.
Image to Video
Section titled “Image to Video”Generate a video from one or more input images using any video model that supports Image-to-Video generation on ImageRouter.
Image-to-Video is in Beta, this API can change later.
curl 'https://api.imagerouter.io/v1/openai/videos/generations' \-H 'Authorization: Bearer YOUR_API_KEY' \-F 'prompt=YOUR_PROMPT' \-F 'model=ir/test-video' \-F 'image[]=@your_image1.webp'const formData = new FormData()formData.append('prompt', 'YOUR_PROMPT')formData.append('model', 'ir/test-video')
// Add up to 16 imagesconst imgBlob = await fetch('your_image1.webp').then(r => r.blob())formData.append('image[]', imgBlob)
const response = await fetch('https://api.imagerouter.io/v1/openai/videos/generations', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY' }, body: formData})
const data = await response.json()console.log(data)import requests
url = "https://api.imagerouter.io/v1/openai/videos/generations"headers = {"Authorization": "Bearer YOUR_API_KEY"}
payload = { "prompt": "YOUR_PROMPT", "model": "ir/test-video"}
with open("your_image1.webp", "rb") as image_file: files = {"image[]": image_file} response = requests.post(url, files=files, data=payload, headers=headers) print(response.json())Parameters
Section titled “Parameters”- Same as Text to Video parameters, plus:
image[]One or more input images.