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.

Create
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.

Poll
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.

Download
curl --fail-with-body https://api.minirouter.sh/v1/videos/$VIDEO_ID/content \
  -H "Authorization: Bearer $MINIROUTER_KEY" \
  --output video.mp4

Use the OpenAI SDK

Point the client at MiniRouter and turn off retries: a retried create starts a second video.

video.mjs
// 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()));

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 Previewalibaba/wan-v2.5-t2v-preview
    720p, 1080p · 5 or 10 seconds · from $0.105/s
  • Wan v2.6 Image-to-Videoalibaba/wan-v2.6-i2v
    720p, 1080p · 2–15 seconds · from $0.105/s
  • Wan v2.6 Image-to-Video Flashalibaba/wan-v2.6-i2v-flash
    720p, 1080p · 2–15 seconds · from $0.0525/s
  • Wan v2.6 Text-to-Videoalibaba/wan-v2.6-t2v
    720p, 1080p · 2–15 seconds · from $0.105/s
  • Wan v2.7 Text-to-Videoalibaba/wan-v2.7-t2v
    720p, 1080p · 2–15 seconds · from $0.105/s

ByteDance

  • Seedance 2.5bytedance/seedance-2.5
    480p, 720p, 1080p · 4–30 seconds · audio · from $0.107856/s
  • Seedance v1.0 Probytedance/seedance-v1.0-pro
    480p, 720p, 1080p · 2–12 seconds · from $0.025515/s
  • Seedance v1.0 Pro Fastbytedance/seedance-v1.0-pro-fast
    480p, 720p, 1080p · 2–12 seconds · from $0.010185/s
  • Seedance v1.5 Probytedance/seedance-v1.5-pro
    480p, 720p, 1080p · 4–12 seconds · audio · from $0.012705/s

Google

  • Gemini Omni 1.2 Flashgoogle/gemini-omni-1.2-flash
    360p, 720p, 1080p, 4K · 3–15 seconds · from $0.024331/s
  • Veo 3.1google/veo-3.1-generate-001
    720p, 1080p, 4K · 4, 6 or 8 seconds · audio · from $0.21/s
  • Veo 3.1 Fast Generategoogle/veo-3.1-fast-generate-001
    720p, 1080p, 4K · 4, 6 or 8 seconds · audio · from $0.105/s
  • Veo 3.1 Lite Generategoogle/veo-3.1-lite-generate-001
    720p, 1080p · 4, 6 or 8 seconds · audio · from $0.0315/s

Kling AI

  • Kling v2.5 Turbo Image-to-Videoklingai/kling-v2.5-turbo-i2v
    720p, 1080p · 5 or 10 seconds · from $0.0441/s
  • Kling v2.5 Turbo Text-to-Videoklingai/kling-v2.5-turbo-t2v
    720p, 1080p · 5 or 10 seconds · from $0.0441/s
  • Kling v2.6 Image-to-Videoklingai/kling-v2.6-i2v
    720p, 1080p · 5 or 10 seconds · audio · from $0.0441/s
  • Kling v2.6 Text-to-Videoklingai/kling-v2.6-t2v
    720p, 1080p · 5 or 10 seconds · audio · from $0.0441/s
  • Kling v3.0 Image-to-Videoklingai/kling-v3.0-i2v
    720p, 1080p · 3–15 seconds · audio · from $0.1764/s
  • Kling v3.0 Text-to-Videoklingai/kling-v3.0-t2v
    720p, 1080p · 3–15 seconds · audio · from $0.1764/s

MiniMax

  • MiniMax H3minimax/minimax-h3
    768p, 2K · 4–15 seconds · from $0.084/s
  • MiniMax H3 Maxminimax/minimax-h3-max
    480p, 768p · 5–15 seconds · from $0.0525/s

xAI

  • Grok Imaginespacexai/grok-imagine-video
    480p, 720p · 1–15 seconds · from $0.0525/s
  • Grok Imagine Video 1.5spacexai/grok-imagine-video-1.5
    480p, 720p, 1080p · 1–15 seconds · from $0.084/s
  • Grok Imagine Video 1.5 Litespacexai/grok-imagine-video-1.5-lite
    480p, 720p, 1080p · 1–15 seconds · from $0.021/s

List models in code

Video models are the GET /v1/models entries with "type": "video".

List video models
curl -s https://api.minirouter.sh/v1/models | jq '.data[]
  | select(.type == "video")
  | {id, controls: .video.controls, prices: .video.pricing.prices}'
FieldMeaning
video.controls.sizesAccepted size values, each with a price tier and aspect_ratio. A size with max_seconds accepts durations up to that value.
video.controls.secondsAccepted durations.
video.controls.audiotrue if the model can add sound.
video.controls.image_urloptional or required if the model starts from an image, otherwise false.
video.controls.max_prompt_charsLongest accepted prompt.
video.pricing.pricesusd_per_second by tier and audio. When a row includes aspect_ratio, match it to the selected size too.

Request body

FieldRule
modelRequired. A video model id.
promptRequired. Up to max_prompt_chars characters.
secondsRequired. One of video.controls.seconds, as a number or string.
sizeRequired. One of video.controls.sizes, such as 1280x720.
audioOptional, default false. true adds sound where the model supports it, at the audio price.
image_urlA 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_idA 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.

  1. 01StartCreate an upload with the file's media type and byte length.
  2. 02Send partsUpload each 3 MiB part, in order, using the same source ID.
  3. 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.

upload.mjs
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);
Create from the uploaded image
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}')"
EndpointUse
POST /v1/videos/sourcesJSON with mime_type and bytes starts an upload. JSON with video_id copies an eligible completed video on your account.
PUT /v1/videos/sources/{id}/parts/{index}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 /v1/videos/sources/{id}/completeChecks all parts and decodes the source. Returns the ready source object.
POST /v1/videos/sources/{id}/deriveCrop or resize a ready source into a new private source with width, height and fit.
GET /v1/videos/sources/{id}Read source metadata, including dimensions, duration and expiry.
GET /v1/videos/sources/{id}/contentPreview the original media with your account's API key.
DELETE /v1/videos/sources/{id}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.

Fit a source into a square
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.

Create an edit after completing a video source upload
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.

Video object
{
  "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

statusMeaning
queuedAccepted, not started yet.
in_progressGenerating.progress is 0 while queued, 50 while generating and 100 when completed.
completedReady to download until expires_at.
failederror says why. Nothing is charged.

Cost status

cost.statusMeaning
pendingCredit is held. usd is null.A completed video stays pending until the provider reports its cost.
settledusd is the final charge.
releasedThe 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.

  1. 01HoldThe extra second covers clips that run long. The minimum hold is $0.00002.At create: (seconds + 1) × the per-second price.
  2. 02GenerateA failed or cancelled video releases the hold.
  3. 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

CodeCause
invalid_request400. A field is missing, unsupported or not in video.controls, or the provider refused the prompt. Nothing is charged.
insufficient_credits402. Your balance cannot cover the hold.
rate_limited429. Too many requests on this key, polls included.
videos_unavailable503. Video is paused, or your account already has 2 videos in progress. Nothing is charged.
video_capacity503. Provider or download capacity is full. Retry after Retry-After.
video_request_failed502. 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_found404. No video with this id on your account.
video_not_ready409. Not completed yet. Failed videos have no content.
video_expired410. More than 24 hours since completion.
video_content_unavailable502. The download failed. Retry; downloads are free.

Other codes are in Errors.

Choose your path