/omni/media/v1/contents/generations/tasks影片生成
影片生成是非同步的:先建立任务(202 + task id),轮询到终态后再读签章 URL。base URL 与 atp- 密钥同图像。Gateway 把 unified model 路由到影片供应商,同名可容错切换。
- POST
…/contents/generations/tasks - GET
…/contents/generations/tasks/{id}
- 成功的任务带
content.video_url——带签章的边缘 URL,TTL 30 分钟。逾期后任务仍回succeeded但video_url为null且expired: true(需重建重生)。 - 当项目(project)余额 ≤ 0,请求会以
402 insufficient_quota拒绝。
可用的影片模型#
名称以 GET /v1/models 确认。
请使用建立任务时的同一把密钥呼叫 GET https://api.atptoken.ai/v1/models。模型未出现在回应中,就不能由该项目使用;安装 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_..." }content[] 区块——每个区块是 { "type": "text" | "image_url" | "video_url" | "audio_url", ... }。
- 只有文字 → 文生影片;含图片 → 图生影片。
image_url/video_url带{ "url": "…" }。role为first_frame/last_frame/reference_image/reference_video。
url 接受哪些形式#
影片端点接受公开 https:// URL;Seedance 另外接受素材 API 产生的 asset:// URI。
图片端点收到 asset:// 引用时,会在生成阶段回 provider_error / generation_failed。
引用上传的文件#
要引用自己上传的文件,先把它换成公开 URL:
# 1. upload — the response key is `id` (an_<ULID>), not gw_file_id
curl -s https://api.atptoken.ai/v1/files \
-H "Authorization: Bearer atp-..." -F "file=@./first-frame.png"
# → 201 { "id": "an_01H...", "object": "file", "bytes": 152340, ... }
# 2. resolve to a no-auth URL — read the 302 Location, do NOT follow it
curl -sD - -o /dev/null https://api.atptoken.ai/v1/files/an_01H... \
-H "Authorization: Bearer atp-..." | grep -i '^location:'
# → location: https://<object-store>/gateway-files/...?<presigned> (~15-minute TTL)把那个 Location 值当 url 用。它免验证即可下载——正是上游供应商需要的——但约 15 分钟就过期,所以请在建立任务前才解析,不要快取。
引用登记的素材#
Seedance 也接受通过素材 API 登记的图片。登记图片、等到状态为 Completed,再把回传的 AssetUri(asset://…,请原样使用)当图片区块的 url:
- POST
/omni/media/v1/asset-groups - POST
/omni/media/v1/assets - POST
/omni/media/v1/assets/get - POST
…/contents/generations/tasks
{ "type": "image_url", "image_url": { "url": "asset://…" }, "role": "reference_image" }URI 只放在 image_url.url,区块没有顶层 url。/v1/files 的 id 不是素材 URI。
轮询至终态#
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=..." } }阿里影片模型#
wan-2-7-t2v/wan-2-7-i2v 与 HappyHorse 的文生/图生/参考图模型与其他影片模型共用同一组端点与 content[] 形状,以下只列各模型特有之处。happyhorse-1.0-video-edit 是例外:它服务于另一组 DashScope 相容端点(见下)。
wan-2-7-t2v/wan-2-7-i2v 即使请求 720P 仍回传 1080P 影片,且计费依实际产出计算——5 秒影片会以 1080P 费率计价。请以 1080P 估算预算;若需要 720P 价位请改用 happyhorse-1.1-*。
这些模型支持 720P 与 1080P。请求 480P 不会被拒绝——会以约 1080P 产出并按 1080P 费率计费。需要 720P 价位请明确送 720P。
文生影片#
curl https://api.atptoken.ai/omni/media/v1/contents/generations/tasks \
-H "Authorization: Bearer atp-..." -H "Content-Type: application/json" \
-d '{
"model": "happyhorse-1.1-t2v",
"content": [{ "type": "text", "text": "a horse galloping across a green field" }],
"resolution": "720P", "ratio": "16:9", "duration": 5,
"watermark": false
}'图生影片#
加一个 role: "first_frame" 的图片区块:
"content": [
{ "type": "text", "text": "the subject turns slowly toward the camera" },
{ "type": "image_url", "image_url": { "url": "https://example.com/first.jpg" }, "role": "first_frame" }
]参考图生影片#
happyhorse-1.1-r2v 接受 1 至 9 张参考图,每张带 role: "reference_image",在 prompt 中以 [Image 1]、[Image 2] 指代:
"content": [
{ "type": "text", "text": "[Image 1] walks into the room shown in [Image 2]" },
{ "type": "image_url", "image_url": { "url": "https://example.com/person.jpg" }, "role": "reference_image" },
{ "type": "image_url", "image_url": { "url": "https://example.com/room.jpg" }, "role": "reference_image" }
]kling-o3-pro-reference 带多张 reference_image、在 prompt 写「把 [Image 1] 放进 [Image 2] 的场景」时,跨图合成指示不一定会执行,任务仍会出片并计费。批量生成前,先跑一支短的低解析度影片确认。
影片编辑#
happyhorse-1.0-video-edit 请使用 DashScope 相容端点,不是统一端点。 统一端点会以 400 video-edit requires a source video 拒绝此模型。改以 input.media[] 建立任务,并轮询 GET /omni/media/v1/tasks/{id}:
curl https://api.atptoken.ai/omni/media/v1/services/aigc/video-generation/video-synthesis \
-H "Authorization: Bearer atp-..." -H "Content-Type: application/json" \
-H "Idempotency-Key: my-stable-key-123" \
-d '{
"model": "happyhorse-1.0-video-edit",
"input": {
"prompt": "replace the background with a snowy street",
"media": [
{ "type": "video", "url": "https://example.com/source.mp4" },
{ "type": "reference_image", "url": "https://example.com/style.jpg" }
]
},
"parameters": { "resolution": "720P", "watermark": false }
}'
# → 202 { "output": { "task_id": "cgt_...", "task_status": "PENDING" } }
curl https://api.atptoken.ai/omni/media/v1/tasks/cgt_... -H "Authorization: Bearer atp-..."
# → { "output": { "task_status": "SUCCEEDED", "video_url": "https://media.atptoken.ai/v/..." }, "usage": { … } }input.media[].type只接受video与reference_image,网址栏位名为url(不是video_url)。- 来源影片与每一张参考图都必须是公网免鉴权可直接下载的文件;任一个抓不到时任务会以
FAILED+Failed to download …结束且不计费。 - 此端点回传 DashScope 形状(
output.task_status、output.video_url),且输出长度依来源影片长度,而非parameters.duration。
其他模型特性#
- 浮水印:HappyHorse 浮水印默认开启——需传
watermark: false关闭;Wan 2.7 默认关闭。 - 画面比例:HappyHorse 在共用清单之外另支持
4:5、5:4、9:21、21:9。 - Prompt 长度:5,000 字元(HappyHorse 中文 2,500 字)。
- 这些模型尚未支持
generate_audio。