媒體 API
POST
/omni/media/v1/contents/generations/tasks影片生成
影片生成是非同步的:先建立任務(202 + task id),輪詢到終態後再讀簽章 URL。base URL 與 atp- key 同圖像。gateway 把 unified model 路由到影片 provider,同名可容錯切換。可用影片模型:seedance-2-0(標準)、seedance-2-0-mini(輕量/較省)、seedance-2-0-fast(加速),及 Kling 系列(preview):kling-v3-standard/-pro、kling-o3-standard/-pro(含 -i2v/-reference/-reference-7/-v2v/-video-edit 變體)——均按秒×解析度計費(Kling 音訊生成暫未開放);以 GET /v1/models 確認。
- 成功的任務帶
content.video_url——帶簽章的邊緣 URL,TTL 30 分鐘。逾期後任務仍回succeeded但video_url為null且expired: true(需重建重生)。 - 當 project 餘額 ≤ 0,請求會以
402 insufficient_quota拒絕。
先確認模型與 project 權限
請使用建立任務時的同一把 key 呼叫 GET https://api.atptoken.ai/v1/models。模型未出現在回應中,就不能由該 project 使用;安裝 Skill 或知道模型名稱不會繞過 allowed models。
建立任務
curl https://api.atptoken.ai/omni/media/v1/contents/generations/tasks \
-H "Authorization: Bearer atp-..." -H "Content-Type: application/json" \
-H "Idempotency-Key: my-stable-key-123" \
-d '{
"model": "seedance-2-0",
"content": [
{ "type": "text", "text": "a red fox running through snow, cinematic" },
{ "type": "image_url", "image_url": { "url": "https://example.com/first.jpg" }, "role": "first_frame" }
],
"resolution": "720p",
"ratio": "16:9",
"duration": 5
}'
# → 202 { "id": "task_..." }| Field | Type | Description |
|---|---|---|
| model | string · 必填 | unified video model (`video` pool) |
| content | array · 必填 | multimodal input blocks (see below) |
| resolution | string | `480p` / `720p` / `1080p` / `4k` |
| ratio | string | `16:9` `9:16` `4:3` `3:4` `1:1` `21:9` `adaptive` (alias `aspect_ratio`) |
| duration | integer | seconds (mutually exclusive with `frames`) |
| frames | integer | frame count (alt to `duration`) |
| generate_audio | boolean | add a soundtrack (alias `add_audio`) |
| seed | integer | |
| watermark | boolean |
content[] 區塊 — 每個區塊是 { "type": "text" | "image_url" | "video_url" | "audio_url", ... }。只有文字 → 文生影片;含圖片 → 圖生影片。image_url/video_url 帶 { "url": "<https | base64 | asset://pid.id>" };role 為 first_frame / last_frame / reference_image / reference_video。
輪詢至終態
curl https://api.atptoken.ai/omni/media/v1/contents/generations/tasks/task_... \
-H "Authorization: Bearer atp-..."
# → { "status": "succeeded", "content": { "video_url": "https://media-prod.atptoken.ai/v/...mp4?exp=...&sig=..." } }| 方法 | 路徑 | 動作 |
|---|---|---|
| POST | /omni/media/v1/contents/generations/tasks | create |
| GET | /omni/media/v1/contents/generations/tasks/{id} | poll |
| GET | /omni/media/v1/contents/generations/tasks | list |
| DELETE | /omni/media/v1/contents/generations/tasks/{id} | cancel |
錯誤
400
invalid request body.
402
`insufficient_quota`:project balance ≤ 0(僅阻擋 create;poll / list / cancel 仍可用)。
403
`permission_denied`:gated model 尚未對此 project 開放。
422
the model has no video provider.
502
upstream generation failed.