Video Inputs
Send video to compatible TheRouter.ai models for temporal analysis
Video content is sent through video_url parts in chat completions. TheRouter.ai supports provider- compatible URLs and base64 data URLs for local video files.
Provider-specific URL support
Video URLs are not universal. Some providers only accept specific sources (for example, YouTube links on certain Gemini routes). Use base64 as a fallback when URL ingestion is unsupported.
Video URL example
TypeScript
const response = await fetch("https://api.therouter.ai/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer <THEROUTER_API_KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "google/gemini-2.5-flash",
messages: [
{
role: "user",
content: [
{ type: "text", text: "Describe key events in this clip" },
{
type: "video_url",
video_url: {
url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
},
},
],
},
],
}),
});Base64 video example
base64-video.ts
import fs from "node:fs/promises";
const video = await fs.readFile("./demo.mp4");
const dataUrl = "data:video/mp4;base64," + video.toString("base64");
await fetch("https://api.therouter.ai/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer <THEROUTER_API_KEY>",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "google/gemini-2.5-flash",
messages: [
{
role: "user",
content: [
{ type: "text", text: "List every scene transition and timestamp." },
{ type: "video_url", video_url: { url: dataUrl } },
],
},
],
}),
});Formats and frame handling
video-formats.txt
video/mp4
video/mpeg
video/mov
video/webmModels typically sample frames internally. For best outcomes, keep clips focused, compress unnecessary duration, and provide explicit analysis instructions.
Quality strategy
If analysis quality is low, trim to the relevant segment first and avoid oversized 4K payloads when 720p is sufficient for the task.