Lunos mendukung input video untuk model yang kompatibel melalui API Chat Completions. Video dapat dikirimkan dalam dua cara: menggunakan URL publik atau data URL Base64.
Catatan: Dukungan terhadap URL video bersifat spesifik per provider. Pada beberapa rute model Gemini, hanya tautan YouTube yang diterima, sedangkan rute lainnya mewajibkan format Base64.
POST /v1/chat/completions
Sertakan video di dalam array content dengan tipe "video_url":
{
"type": "video_url",
"video_url": {
"url": "https://example.com/video.mp4"
}
}
Hanya model yang memiliki kapabilitas input video yang bisa memproses payload ini. Pastikan metadata model tersebut memiliki "video" di dalam properti inputModalities.
curl -X POST "https://api.lunos.tech/v1/chat/completions" \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-2.5-flash",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Jelaskan apa yang terjadi pada video ini." },
{ "type": "video_url", "video_url": { "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" } }
]
}
]
}'
import requests
payload = {
"model": "google/gemini-2.5-flash",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "Jelaskan apa yang terjadi pada video ini."},
{
"type": "video_url",
"video_url": {"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"},
},
],
}
],
}
response = requests.post(
"https://api.lunos.tech/v1/chat/completions",
headers={
"Authorization": "Bearer YOUR_SECRET_KEY",
"Content-Type": "application/json",
},
json=payload,
)
print(response.json())
const response = await fetch("https://api.lunos.tech/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_SECRET_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "google/gemini-2.5-flash",
messages: [
{
role: "user",
content: [
{ type: "text", text: "Jelaskan apa yang terjadi pada video ini." },
{
type: "video_url",
video_url: { url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ" },
},
],
},
],
}),
});
console.log(await response.json());
Gunakan metode ini untuk file video lokal/pribadi, atau saat provider model tidak mendukung URL video langsung.
import base64
import requests
def encode_video(path):
with open(path, "rb") as f:
return base64.b64encode(f.read()).decode("utf-8")
base64_video = encode_video("path/to/video.mp4")
data_url = f"data:video/mp4;base64,{base64_video}"
payload = {
"model": "google/gemini-2.5-flash",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "Apa yang terlihat dalam video ini?"},
{"type": "video_url", "video_url": {"url": data_url}},
],
}
],
}
response = requests.post(
"https://api.lunos.tech/v1/chat/completions",
headers={
"Authorization": "Bearer YOUR_SECRET_KEY",
"Content-Type": "application/json",
},
json=payload,
)
print(response.json())
import { readFile } from "node:fs/promises";
async function encodeVideo(path: string) {
const buffer = await readFile(path);
return `data:video/mp4;base64,${buffer.toString("base64")}`;
}
const dataUrl = await encodeVideo("path/to/video.mp4");
const response = await fetch("https://api.lunos.tech/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_SECRET_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "google/gemini-2.5-flash",
messages: [
{
role: "user",
content: [
{ type: "text", text: "Apa yang terlihat dalam video ini?" },
{ type: "video_url", video_url: { url: dataUrl } },
],
},
],
}),
});
console.log(await response.json());
video/mp4video/mpegvideo/movvideo/webm"video" pada atribut inputModalities.Tidak ada judul di halaman ini.
