API Video

Buat, polling, dan unduh tugas video asinkron

Generasi video menggunakan model tugas asinkron: buat → polling status → unduh hasil. Gateway menyediakan dua path pembuatan; endpoint kueri dan unduhan dibagi bersama.

1. Ringkasan

Alur asinkron

Buat tugas → Poll GET /v1/videos/{task_id} → Unduh GET /v1/videos/{task_id}/content
  1. Panggil POST /v1/videos atau POST /v1/multi/videos untuk mengirim tugas dan menerima task_id
  2. Poll GET /v1/videos/{task_id} hingga status adalah completed atau failed
  3. Setelah selesai, unduh melalui GET /v1/videos/{task_id}/content; opsional gunakan ?variant=thumbnail untuk gambar sampul

Membandingkan dua path pembuatan

ItemPOST /v1/videosPOST /v1/multi/videos
Use casePembuatan video umum; field mengikuti konvensi model video upstreamGenerasi video multimodal via mode + assets[]
Content-Typeapplication/json atau multipart/form-dataapplication/json
Param intimodel, prompt, size, seconds, input_referencemodel, mode, prompt, assets[], resolution, duration_sec, dll.
Gambar referensiURL JSON / data URI Base64 / unggah file multipartKirim URL di assets[] berdasarkan role
Mode generasiTanpa field mode; ditentukan oleh model dan field permintaanmode eksplisit: t2v, i2v, first_frame, first_last_frame, ref_image, video_extend, video_edit
Kueri & unduhGET /v1/videos/{task_id}, GET /v1/videos/{task_id}/contentSama (dibagi)

Prasyarat: model harus berupa model dari API Model yang supported_endpoint_types-nya mencakup openai-video.


2. Endpoint

MethodPathDeskripsi
POST/v1/videosBuat tugas video (umum)
GET/v1/videos/{task_id}Kueri status tugas
GET/v1/videos/{task_id}/contentUnduh video atau thumbnail
POST/v1/multi/videosBuat tugas video (multimodal / YunSell AI)

3. Status tugas

ItemDeskripsi
Format ID tugasID publik berbentuk task_xxxxxxxx
Alur statusqueued → in_progress → completed / failed
statusDeskripsi
queuedDalam antrean
in_progressSedang dihasilkan
completedSelesai; siap diunduh
failedGagal; lihat field error

4. POST /v1/videos

Buat tugas video.

Auth: Bearer Token

Content-Type: application/json atau multipart/form-data

Body permintaan (JSON)

{
  "model": "sora-2",
  "prompt": "A cinematic shot of a cat walking on the beach at sunset, soft ocean waves, warm golden lighting",
  "size": "1280x720",
  "seconds": 8
}

Field permintaan

FieldTipeWajibDeskripsi
modelstringYaNama model video
promptstringYaDeskripsi video (≤ 2500 karakter)
sizestringBersyaratResolusi, mis. 1280x720, 720x1280; wajib untuk model seperti sora-2
secondsint / stringBersyaratDurasi dalam detik; sora-2 mengizinkan 4/8/12/16/20
input_referenceobject / fileTidakGambar referensi

Dengan gambar referensi (URL JSON):

{
  "model": "sora-2",
  "prompt": "Animate this image with a slight camera move",
  "size": "1280x720",
  "seconds": 8,
  "input_reference": {
    "image_url": "https://example.com/ref.jpg"
  }
}

Dengan gambar referensi (data URI Base64):

{
  "model": "sora-2",
  "prompt": "Animate this image with a slight camera move",
  "size": "1280x720",
  "seconds": 8,
  "input_reference": {
    "image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
  }
}

multipart/form-data: input_reference adalah field form file; field lain menggunakan nama yang sama.

Contoh permintaan (curl)

JSON:

curl http://www.mangoto.ai/v1/videos \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "prompt": "A cinematic shot of a cat walking on the beach at sunset, soft ocean waves, warm golden lighting",
    "size": "1280x720",
    "seconds": 8
  }'

Dengan gambar referensi (JSON):

curl http://www.mangoto.ai/v1/videos \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "prompt": "Animate this image with a slight camera move",
    "size": "1280x720",
    "seconds": 8,
    "input_reference": {
      "image_url": "https://example.com/ref.jpg"
    }
  }'

multipart/form-data (unggah gambar referensi):

curl http://www.mangoto.ai/v1/videos \
  -H "Authorization: Bearer sk-xxx" \
  -F "model=sora-2" \
  -F "prompt=Animate this image with a slight camera move" \
  -F "size=1280x720" \
  -F "seconds=8" \
  -F "input_reference=@/path/to/ref.jpg"

Body respons

HTTP 200

{
  "id": "task_abc123xyz",
  "status": "queued",
  "progress": 0,
  "created_at": 1712697600
}

Field respons

FieldTipeDeskripsi
idstringID tugas untuk kueri dan unduhan
statusstringAwalnya queued
progressintegerProgres 0–100
created_atintegerUnix timestamp (detik)

Respons kegagalan

HTTP 400

{
  "code": "invalid_request",
  "message": "seconds must be one of 4, 8, 12, 16, 20"
}
FieldTipeDeskripsi
codestringKode error
messagestringAlasan kegagalan validasi

Lihat Error tugas untuk format error.


5. GET /v1/videos/{task_id}

Kueri status tugas video.

Auth: Bearer Token

Parameter path: task_id — id yang dikembalikan saat membuat tugas

Permintaan: Tanpa body permintaan

Contoh permintaan (curl)

curl http://www.mangoto.ai/v1/videos/task_abc123xyz \
  -H "Authorization: Bearer sk-xxx"

Body respons (sedang berlangsung)

HTTP 200

{
  "id": "task_abc123xyz",
  "object": "video",
  "model": "agnes-video-v2.0",
  "status": "in_progress",
  "progress": 45,
  "created_at": 1712697600,
  "seconds": "5.0",
  "size": "1280x704"
}

Body respons (selesai)

HTTP 200

{
  "id": "task_abc123xyz",
  "object": "video",
  "model": "agnes-video-v2.0",
  "status": "completed",
  "progress": 100,
  "created_at": 1712697600,
  "completed_at": 1712698200,
  "seconds": "5.0",
  "size": "1280x704",
  "remixed_from_video_id": "https://cdn.example.com/videos/video_abc.mp4",
  "error": null,
  "metadata": {
    "url": "https://cdn.example.com/videos/video_abc.mp4"
  }
}

Body respons (gagal)

HTTP 200

{
  "id": "task_abc123xyz",
  "object": "video",
  "model": "agnes-video-v2.0",
  "status": "failed",
  "progress": 100,
  "created_at": 1712697600,
  "error": {
    "message": "upstream generation failed",
    "code": "generation_failed"
  }
}

Field respons

FieldTipeDeskripsi
idstringID tugas; sama dengan id respons pembuatan
objectstringSelalu video
modelstringModel yang digunakan
statusstringStatus tugas; lihat Status tugas
progressintegerProgres 0–100
created_atintegerUnix timestamp dibuat (detik)
completed_atintegerUnix timestamp selesai (detik); dihilangkan saat belum selesai
expires_atintegerUnix timestamp kedaluwarsa hasil (detik); dikembalikan beberapa channel
secondsstringDurasi video dalam detik, mis. "5.0"
sizestringResolusi video, mis. "1280x704"
remixed_from_video_idstringURL hasil video; beberapa channel (mis. Agnes AI) mengembalikan alamat CDN di sini
errorobject / nullInfo error saat gagal; null atau dihilangkan saat berhasil
error.messagestringAlasan kegagalan
error.codestringKode error, mis. generation_failed
metadataobjectMetadata diperluas; kunci umum di bawah

Kunci metadata umum:

KunciTipeDeskripsi
urlstringURL hasil video
thumbnail_urlstringURL thumbnail
durationnumberDurasi aktual (detik)
widthintegerLebar video (piksel)
heightintegerTinggi video (piksel)
fpsintegerFrame rate
seedintegerSeed acak

6. GET /v1/videos/{task_id}/content

Unduh video yang dihasilkan atau thumbnail.

Auth: Bearer Token atau Session konsol admin

Parameter path: task_id

Parameter query:

ParameterDeskripsi
variantOpsional. video (default) mengunduh video; thumbnail mengunduh gambar sampul

Prasyarat: status tugas harus completed.

Contoh permintaan (curl)

Unduh video (ikuti redirect 301):

curl -L http://www.mangoto.ai/v1/videos/task_abc123xyz/content \
  -H "Authorization: Bearer sk-xxx" \
  -o output.mp4

Unduh thumbnail:

curl -L "http://www.mangoto.ai/v1/videos/task_abc123xyz/content?variant=thumbnail" \
  -H "Authorization: Bearer sk-xxx" \
  -o cover.jpg

Respons (sudah disimpan di object storage)

HTTP 301 Moved Permanently

Location: https://cdn.example.com/users/1/tasks/task_abc123xyz/video.mp4
Header / fieldDeskripsi
LocationURL resource object storage atau CDN; klien harus mengikuti redirect
BodyTanpa konten JSON

Respons (gateway mem-proxy upstream)

HTTP 200, body adalah aliran biner (bukan JSON).

HeaderDeskripsi
Content-Typevideo/mp4 (video) atau image/jpeg / image/png (thumbnail)
Content-LengthUkuran file dalam byte
Content-DispositionMungkin menyertakan nama file, mis. attachment; filename="task_abc123xyz.mp4"
BodyData biner video atau thumbnail

Respons error

Tugas belum selesai, HTTP 400:

{
  "error": {
    "message": "Task is not completed yet, current status: in_progress",
    "type": "invalid_request_error"
  }
}

Tugas tidak ditemukan, HTTP 404:

{
  "error": {
    "message": "Task not found",
    "type": "invalid_request_error"
  }
}

Variant tidak valid, HTTP 400:

{
  "error": {
    "message": "invalid variant \"cover\", must be \"video\" or \"thumbnail\"",
    "type": "invalid_request_error"
  }
}

Thumbnail tidak tersedia, HTTP 404:

{
  "error": {
    "message": "Thumbnail not available",
    "type": "invalid_request_error"
  }
}

Lihat Error standar untuk format error.


7. POST /v1/multi/videos

Generasi video multimodal. Tentukan mode generasi dengan mode, dan kirim URL gambar/video melalui assets[].

Setelah submit berhasil, kueri dengan GET /v1/videos/{task_id} dan unduh dengan GET /v1/videos/{task_id}/content.

Auth: Bearer Token

Content-Type: application/json

Mode generasi (mode)

modeDeskripsiAset wajib tipikal
t2vTeks-ke-videoTidak ada
i2vGambar-ke-videoimage
first_frameFrame pertama ke videofirst_frame
first_last_frameFrame pertama dan terakhir ke videofirst_frame, last_frame
ref_imageGambar referensi ke videoMinimal satu reference_images
video_extendPerpanjang / lanjutkan videosource_video
video_editEdit video cerdassource_video; opsional reference_images

Nilai mode yang diaktifkan per model mengikuti konfigurasi konsol admin Kemampuan model → Kemampuan video.

Field permintaan

FieldTipeWajibDeskripsi
modelstringYaModel video
modestringYaMode generasi
promptstringBersyaratDeskripsi video; wajib untuk sebagian besar mode
assetsarrayBersyarat[{ "role": "...", "url": "https://..." }]
resolutionstringTidakmis. 720p, 1080p
duration_secnumberTidakDurasi (detik)
aspect_ratiostringTidakmis. 16:9, 3:2
prompt_optimizebooleanTidakApakah mengaktifkan optimasi prompt
gen_tierstringTidakTingkat generasi
qualitystringTidakKualitas
audio_modestringTidakMode audio
camera_controlstringTidakKontrol kamera
shot_typestringTidakJenis shot
hd_upscalestringTidakUpscale HD

Contoh permintaan: teks-ke-video (t2v)

{
  "model": "agnes-video-v2.0",
  "mode": "t2v",
  "prompt": "A cinematic shot of a cat walking on the beach at sunset, soft ocean waves, warm golden lighting, realistic motion",
  "resolution": "720p",
  "duration_sec": 5,
  "aspect_ratio": "3:2",
  "prompt_optimize": false
}

Contoh permintaan: frame pertama ke video (first_frame)

{
  "model": "agnes-video-v2.0",
  "mode": "first_frame",
  "prompt": "The woman slowly turns around and looks back at the camera, natural facial expression, cinematic camera movement",
  "assets": [
    { "role": "first_frame", "url": "https://example.com/image.png" }
  ],
  "duration_sec": 5
}

Contoh permintaan: gambar referensi ke video (ref_image)

{
  "model": "agnes-video-v2.0",
  "mode": "ref_image",
  "prompt": "Create a smooth transformation scene between the two reference images, cinematic lighting, consistent character identity, natural motion",
  "assets": [
    { "role": "reference_images", "url": "https://example.com/image1.png" },
    { "role": "reference_images", "url": "https://example.com/image2.png" }
  ],
  "duration_sec": 5
}

Contoh permintaan: perpanjang video (video_extend)

{
  "model": "wan2.6-t2v",
  "mode": "video_extend",
  "prompt": "Continue the scene with the character walking into the sunset",
  "assets": [
    { "role": "source_video", "url": "https://example.com/source.mp4" }
  ],
  "duration_sec": 5,
  "resolution": "720p"
}

Contoh permintaan (curl)

Teks-ke-video (t2v):

curl http://www.mangoto.ai/v1/multi/videos \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-video-v2.0",
    "mode": "t2v",
    "prompt": "A cinematic shot of a cat walking on the beach at sunset, soft ocean waves, warm golden lighting, realistic motion",
    "resolution": "720p",
    "duration_sec": 5,
    "aspect_ratio": "3:2",
    "prompt_optimize": false
  }'

Frame pertama ke video (first_frame):

curl http://www.mangoto.ai/v1/multi/videos \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-video-v2.0",
    "mode": "first_frame",
    "prompt": "The woman slowly turns around and looks back at the camera, natural facial expression, cinematic camera movement",
    "assets": [
      {"role": "first_frame", "url": "https://example.com/image.png"}
    ],
    "duration_sec": 5
  }'

Gambar referensi ke video (ref_image):

curl http://www.mangoto.ai/v1/multi/videos \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agnes-video-v2.0",
    "mode": "ref_image",
    "prompt": "Create a smooth transformation scene between the two reference images, cinematic lighting, consistent character identity, natural motion",
    "assets": [
      {"role": "reference_images", "url": "https://example.com/image1.png"},
      {"role": "reference_images", "url": "https://example.com/image2.png"}
    ],
    "duration_sec": 5
  }'

Perpanjang video (video_extend):

curl http://www.mangoto.ai/v1/multi/videos \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.6-t2v",
    "mode": "video_extend",
    "prompt": "Continue the scene with the character walking into the sunset",
    "assets": [
      {"role": "source_video", "url": "https://example.com/source.mp4"}
    ],
    "duration_sec": 5,
    "resolution": "720p"
  }'

Body respons

HTTP 200

{
  "id": "task_abc123xyz",
  "status": "queued",
  "progress": 0,
  "created_at": 1712697600
}

Field respons

Sama dengan respons pembuatan POST /v1/videos.

FieldTipeDeskripsi
idstringID tugas untuk kueri dan unduhan berikutnya
statusstringAwalnya queued
progressintegerProgres 0–100
created_atintegerUnix timestamp dibuat (detik)

Kueri dan unduhan berikutnya menggunakan GET /v1/videos/{task_id} dan GET /v1/videos/{task_id}/content. Field respons ada di Bagian 5 dan Bagian 6.

Respons kegagalan

HTTP 400

{
  "code": "invalid_request",
  "message": "model and mode are required"
}
{
  "code": "invalid_request",
  "message": "prompt is required"
}

Lihat Error tugas untuk format error.


8. Alur video asinkron yang disarankan

1. POST /v1/videos atau POST /v1/multi/videos
   → dapatkan task_id

2. Poll GET /v1/videos/{task_id}
   → lanjutkan menunggu saat status = queued / in_progress
   → periksa error saat status = failed
   → lanjutkan saat status = completed

3. GET /v1/videos/{task_id}/content
   → unduh file video

4. (Opsional) GET /v1/videos/{task_id}/content?variant=thumbnail
   → unduh thumbnail

Interval polling yang disarankan: 3–10 detik, untuk menghindari rate limiting dari permintaan yang terlalu sering.