Build
Video API
Turn a prompt or an image into an MP4: create a video, poll it, then download it.
1. Create a video
Set MINIROUTER_KEY to a funded API key. This starts a 4-second clip, holds credit and saves its id.
curl --fail-with-body --retry 0 https://api.minirouter.sh/v1/videos \
-H "Authorization: Bearer $MINIROUTER_KEY" \
-H "Content-Type: application/json" \
--data '{
"model": "google/veo-3.1-lite-generate-001",
"prompt": "A paper boat drifting down a rainy street at dusk",
"seconds": 4,
"size": "1280x720"
}' | tee video.json
VIDEO_ID=$(jq -r .id video.json)2. Poll until it finishes
Repeat every 10 seconds until status is completed or failed.
curl --fail-with-body https://api.minirouter.sh/v1/videos/$VIDEO_ID \
-H "Authorization: Bearer $MINIROUTER_KEY"3. Download the MP4
Downloads are free for 24 hours after completion.
curl --fail-with-body https://api.minirouter.sh/v1/videos/$VIDEO_ID/content \
-H "Authorization: Bearer $MINIROUTER_KEY" \
--output video.mp4Use the OpenAI SDK
Point the client at MiniRouter and turn off retries: a retried create starts a second video.
// npm install openai@7.4.0
import OpenAI from 'openai';
import { writeFile } from 'node:fs/promises';
import { setTimeout as sleep } from 'node:timers/promises';
const client = new OpenAI({
baseURL: 'https://api.minirouter.sh/v1',
apiKey: process.env.MINIROUTER_KEY,
maxRetries: 0,
});
let video = await client.videos.create({
model: 'google/veo-3.1-lite-generate-001',
prompt: 'A paper boat drifting down a rainy street at dusk',
seconds: '4', size: '1280x720',
});
while (video.status === 'queued' || video.status === 'in_progress') {
await sleep(10_000);
video = await client.videos.retrieve(video.id);
}
if (video.status === 'failed') throw new Error(video.error?.message);
const content = await client.videos.downloadContent(video.id);
await writeFile('video.mp4', Buffer.from(await content.arrayBuffer()));# pip install openai==2.53.0
import os
from openai import OpenAI
client = OpenAI(
base_url='https://api.minirouter.sh/v1',
api_key=os.environ['MINIROUTER_KEY'],
max_retries=0,
)
video = client.videos.create_and_poll(
model='google/veo-3.1-lite-generate-001',
prompt='A paper boat drifting down a rainy street at dusk',
seconds='4',
size='1280x720',
poll_interval_ms=10_000,
)
if video.status == 'failed':
raise RuntimeError(video.error.message)
client.videos.download_content(video.id).write_to_file('video.mp4')Only create, retrieve and download are supported. Values from video.controls work even where the SDK types omit them; TypeScript needs a cast.
Choose a model
Video models in the live catalog. Open a model for its full price table, or copy its ID.
24 models for video
Alibaba
- Wan v2.5 Text-to-Video Preview720p, 1080p · 5 or 10 seconds · from $0.105/s
alibaba/wan-v2.5-t2v-preview - Wan v2.6 Image-to-Video720p, 1080p · 2–15 seconds · from $0.105/s
alibaba/wan-v2.6-i2v - Wan v2.6 Image-to-Video Flash720p, 1080p · 2–15 seconds · from $0.0525/s
alibaba/wan-v2.6-i2v-flash - Wan v2.6 Text-to-Video720p, 1080p · 2–15 seconds · from $0.105/s
alibaba/wan-v2.6-t2v - Wan v2.7 Text-to-Video720p, 1080p · 2–15 seconds · from $0.105/s
alibaba/wan-v2.7-t2v
ByteDance
- Seedance 2.5480p, 720p, 1080p · 4–30 seconds · audio · from $0.107856/s
bytedance/seedance-2.5 - Seedance v1.0 Pro480p, 720p, 1080p · 2–12 seconds · from $0.025515/s
bytedance/seedance-v1.0-pro - Seedance v1.0 Pro Fast480p, 720p, 1080p · 2–12 seconds · from $0.010185/s
bytedance/seedance-v1.0-pro-fast - Seedance v1.5 Pro480p, 720p, 1080p · 4–12 seconds · audio · from $0.012705/s
bytedance/seedance-v1.5-pro
- Gemini Omni 1.2 Flash360p, 720p, 1080p, 4K · 3–15 seconds · from $0.024331/s
google/gemini-omni-1.2-flash - Veo 3.1720p, 1080p, 4K · 4, 6 or 8 seconds · audio · from $0.21/s
google/veo-3.1-generate-001 - Veo 3.1 Fast Generate720p, 1080p, 4K · 4, 6 or 8 seconds · audio · from $0.105/s
google/veo-3.1-fast-generate-001 - Veo 3.1 Lite Generate720p, 1080p · 4, 6 or 8 seconds · audio · from $0.0315/s
google/veo-3.1-lite-generate-001
Kling AI
- Kling v2.5 Turbo Image-to-Video720p, 1080p · 5 or 10 seconds · from $0.0441/s
klingai/kling-v2.5-turbo-i2v - Kling v2.5 Turbo Text-to-Video720p, 1080p · 5 or 10 seconds · from $0.0441/s
klingai/kling-v2.5-turbo-t2v - Kling v2.6 Image-to-Video720p, 1080p · 5 or 10 seconds · audio · from $0.0441/s
klingai/kling-v2.6-i2v - Kling v2.6 Text-to-Video720p, 1080p · 5 or 10 seconds · audio · from $0.0441/s
klingai/kling-v2.6-t2v - Kling v3.0 Image-to-Video720p, 1080p · 3–15 seconds · audio · from $0.1764/s
klingai/kling-v3.0-i2v - Kling v3.0 Text-to-Video720p, 1080p · 3–15 seconds · audio · from $0.1764/s
klingai/kling-v3.0-t2v
MiniMax
- MiniMax H3768p, 2K · 4–15 seconds · from $0.084/s
minimax/minimax-h3 - MiniMax H3 Max480p, 768p · 5–15 seconds · from $0.0525/s
minimax/minimax-h3-max
xAI
- Grok Imagine480p, 720p · 1–15 seconds · from $0.0525/s
spacexai/grok-imagine-video - Grok Imagine Video 1.5480p, 720p, 1080p · 1–15 seconds · from $0.084/s
spacexai/grok-imagine-video-1.5 - Grok Imagine Video 1.5 Lite480p, 720p, 1080p · 1–15 seconds · from $0.021/s
spacexai/grok-imagine-video-1.5-lite
List models in code
Video models are the GET /v1/models entries with "type": "video".
curl -s https://api.minirouter.sh/v1/models | jq '.data[]
| select(.type == "video")
| {id, controls: .video.controls, prices: .video.pricing.prices}'| Field | Meaning |
|---|---|
| video.controls.sizes | Accepted size values, each with a price tier and aspect_ratio. A size with max_seconds accepts durations up to that value. |
| video.controls.seconds | Accepted durations. |
| video.controls.audio | true if the model can add sound. |
| video.controls.image_ | optional or required if the model starts from an image, otherwise false. |
| video.controls.max_ | Longest accepted prompt. |
| video.pricing.prices | usd_per_second by tier and audio. When a row includes aspect_ratio, match it to the selected size too. |
Request body
| Field | Rule |
|---|---|
| model | Required. A video model id. |
| prompt | Required. Up to max_prompt_chars characters. |
| seconds | Required. One of video.controls.seconds, as a number or string. |
| size | Required. One of video.controls.sizes, such as 1280x720. |
| audio | Optional, default false. true adds sound where the model supports it, at the audio price. |
| image_ | A public https image link or a base64 PNG, JPEG or WebP data URL up to 192 KiB decoded. Required where video.controls.image_url is required, refused where it is false. The full request must fit within 300 KiB. |
| source_ | A ready private source on your account. Replaces image_url for uploaded images. Check the model's source controls: image_source for images, video_source for videos. Video sources inherit their output settings. |
Send JSON or multipart fields, up to 300 KiB. File parts and any other field return 400.
HTTPS links must be public so the provider can download them. Inline data URLs send the image bytes directly. Image size and aspect-ratio requirements vary by model. If the job can't use the image, it fails at no charge.
Keep the image's shape close to size. Otherwise the model may crop it, add bars or match the image's shape, and the price tier stays the one you chose.
The price per second is the same with an image. Grok models also add a flat fee of up to $0.0105 per video, which the hold covers.
Upload a private source
In Video Studio, choose Image, then upload a JPEG, PNG or WebP. You can preview, replace or remove it before generating. Your account's sources are private and expire after 24 hours.
- 01StartCreate an upload with the file's media type and byte length.
- 02Send partsUpload each 3 MiB part, in order, using the same source ID.
- 03CompleteValidate the file, then pass the returned source_id when generating.
Images are limited to 16 MiB; MP4 sources to 64 MiB and 2–8.7 seconds. Image and video sources must be 16–4096 pixels on each side and at most 8,847,360 pixels in total; the selected model can impose tighter limits. Source MP4s must decode with H.264, H.265 or AV1 video.
import { readFile } from 'node:fs/promises';
const [filename, mimeType] = process.argv.slice(2);
if (!filename || !mimeType) throw new Error('Usage: node upload.mjs <file> <mime-type>');
const origin = 'https://api.minirouter.sh/v1/videos/sources';
const headers = { Authorization: `Bearer ${process.env.MINIROUTER_KEY}` };
async function checked(response) {
if (!response.ok) throw new Error(await response.text());
return response;
}
const file = await readFile(filename);
const session = await checked(await fetch(origin, {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json' },
body: JSON.stringify({ mime_type: mimeType, bytes: file.length }),
})).then(response => response.json());
for (let offset = 0, index = 0; offset < file.length; offset += session.part_bytes, index++) {
await checked(await fetch(`${origin}/${session.id}/parts/${index}`, {
method: 'PUT',
headers: { ...headers, 'Content-Type': 'application/octet-stream' },
body: file.subarray(offset, offset + session.part_bytes),
}));
}
const source = await checked(await fetch(`${origin}/${session.id}/complete`, {
method: 'POST', headers,
})).then(response => response.json());
console.log(source.id);SOURCE_ID=$(node upload.mjs photo.png image/png)
curl --fail-with-body --retry 0 https://api.minirouter.sh/v1/videos \
-H "Authorization: Bearer $MINIROUTER_KEY" \
-H 'Content-Type: application/json' \
--data "$(jq -n --arg source "$SOURCE_ID" '{model: "alibaba/wan-v2.6-i2v", prompt: "The camera slowly pushes in", seconds: 2, size: "1280x720", source_id: $source}')"| Endpoint | Use |
|---|---|
| POST / | JSON with mime_type and bytes starts an upload. JSON with video_id copies an eligible completed video on your account. |
| PUT / | Raw application/octet-stream bytes. Each part must contain exactly part_bytes (3 MiB), except the final part, which contains the remaining bytes. Indexes start at zero. |
| POST / | Checks all parts and decodes the source. Returns the ready source object. |
| POST / | Crop or resize a ready source into a new private source with width, height and fit. |
| GET / | Read source metadata, including dimensions, duration and expiry. |
| GET / | Preview the original media with your account's API key. |
| DELETE / | Delete an unused source. A source attached to an unresolved job returns 409. |
A source_id belongs to the account that uploaded it. Do not combine it with image_url. The provider receives a temporary source URL; keep source IDs and preview URLs private.
Crop or resize a source
In Video Studio, choose Video, then Change → Reframe & resize. Select a format and choose Crop to fill or Keep full frame. Resizing creates a new private source and keeps the original. You can download the current reference or switch back to Edit video to use a compatible result.
The API accepts a ready image or MP4 source. Send even integer dimensions from 16 to 4096 pixels, within the source pixel limit. Use crop for a centered crop or contain to fit the full frame. Videos return MP4 with their duration and audio; images return PNG. The result has a new source ID and a new 24-hour expiry.
RESIZED_SOURCE_ID=$(curl --fail-with-body --retry 0 https://api.minirouter.sh/v1/videos/sources/$SOURCE_ID/derive \
-H "Authorization: Bearer $MINIROUTER_KEY" \
-H 'Content-Type: application/json' \
--data '{"width":480,"height":480,"fit":"contain"}' | jq -er '.id')This is standard crop/pad/resize processing. It does not perform AI detail enhancement, generate new scenery or start a video generation. Generation models still apply their own source limits to the returned source.
Edit a video
Editing is offered for models with video_source controls and edit pricing. In Studio, choose Video, upload a short MP4 and describe the changes. Edit this video reuses an eligible result from History.
Upload a source between 2 and 8.7 seconds, with a shorter side of 100–480 pixels. The edit keeps its duration and aspect ratio. Do not send seconds, size, audio or image_url.
Available edit price tiers: 480p. The source's inherited output must match a tier in output_prices, under the model's edit pricing.
SOURCE_ID=$(node upload.mjs source.mp4 video/mp4)
curl --fail-with-body --retry 0 https://api.minirouter.sh/v1/videos \
-H "Authorization: Bearer $MINIROUTER_KEY" \
-H 'Content-Type: application/json' \
--data "$(jq -n --arg source "$SOURCE_ID" '{model: "spacexai/grok-imagine-video", prompt: "Change the scene to winter", source_id: $source}')"The estimate includes source seconds × input_usd_per_second plus output seconds × the matching output_prices rate. The hold rounds source duration up to whole seconds and applies the catalog's headroom to both rates. The final charge uses provider cost and stays within the hold.
Read the status
Create and poll return the video object. cost is a MiniRouter extension.
{
"id": "req_5f2c9e8a1b7d4c3e9f6a0b2d8c4e1f7a",
"object": "video",
"model": "google/veo-3.1-lite-generate-001",
"status": "in_progress",
"progress": 50,
"created_at": 1793145600,
"completed_at": null,
"expires_at": null,
"seconds": "4",
"size": "1280x720",
"error": null,
"cost": {
"status": "pending",
"usd": null
}
}Video status
| status | Meaning |
|---|---|
| queued | Accepted, not started yet. |
| in_ | Generating.progress is 0 while queued, 50 while generating and 100 when completed. |
| completed | Ready to download until expires_at. |
| failed | error says why. Nothing is charged. |
Cost status
| cost.status | Meaning |
|---|---|
| pending | Credit is held. usd is null.A completed video stays pending until the provider reports its cost. |
| settled | usd is the final charge. |
| released | The hold was returned. usd is "0". |
Pricing and holds
Prices are per second of output, by size tier, aspect ratio where listed, and audio. They include MiniRouter's 5% fee.
- 01HoldThe extra second covers clips that run long. The minimum hold is $0.00002.At create: (
seconds+ 1) × the per-second price. - 02GenerateA failed or cancelled video releases the hold.
- 03SettleWhat the provider bills, at the listed price and never more than the hold. The rest returns.
For example, 4 seconds at $0.0315 a second holds $0.1575. If the provider bills 4 seconds, you pay $0.126 and $0.0315 returns.
Video is paid from credit; provider keys (BYOK) are not used. Key spend limits apply to the hold.
Limits
- Hours content is kept after completion
- 24
- Videos in progress per account
- 2
- Minutes before a running video is cancelled
- 45
- Charged for a failed video
- $0
A video counts toward the 2 until its cost settles. Polls and downloads count toward your key's rate limit. Only the account that created a video can read it.
Errors
| Code | Cause |
|---|---|
invalid_request | 400. A field is missing, unsupported or not in video.controls, or the provider refused the prompt. Nothing is charged. |
insufficient_credits | 402. Your balance cannot cover the hold. |
rate_limited | 429. Too many requests on this key, polls included. |
videos_unavailable | 503. Video is paused, or your account already has 2 videos in progress. Nothing is charged. |
video_capacity | 503. Provider or download capacity is full. Retry after Retry-After. |
video_request_failed | 502. The create was not confirmed and may still run. Its x-minirouter-request-id is the video id: poll it before creating another. |
video_not_found | 404. No video with this id on your account. |
video_not_ready | 409. Not completed yet. Failed videos have no content. |
video_expired | 410. More than 24 hours since completion. |
video_content_unavailable | 502. The download failed. Retry; downloads are free. |
Other codes are in Errors.


