媒体 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.