快速入门
从零到生成第一段 AI 视频,只需 5 分钟。
关键前提:请先理解 Seedance 2.0 共有 6 个 model。 本 API 没有"自动模式检测",你必须根据输入类型选择正确的
model字段。完整矩阵见 模型总览。
前置条件
- 一个 EvoLink 账号(免费注册)
- 从 API Key 管理页 获取的 API Key
- 一个 HTTP 客户端(cURL、Python、Node.js 等皆可)
Base URL
https://api.evolink.ai
第 1 步:保存 API Key
export EVOLINK_API_KEY="your-api-key-here"
第 2 步:选择正确的 Model
根据你拥有的输入:
| 你的输入 | 使用的 Model |
|---|---|
| 只有文字 prompt | seedance-2.0-text-to-video |
| 1–2 张图片 | seedance-2.0-image-to-video |
| 图 + 视频 + 音频 多模态素材 | seedance-2.0-reference-to-video |
需要更快速度和更低成本?在上面三个 model ID 前加 fast- 即可,例如 seedance-2.0-fast-text-to-video。详见 Fast 系列。
第 3 步:发起第一个请求
下面以 文生视频 为例:
import os
import requests
response = requests.post(
"https://api.evolink.ai/v1/videos/generations",
headers={
"Authorization": f"Bearer {os.environ['EVOLINK_API_KEY']}",
"Content-Type": "application/json"
},
json={
"model": "seedance-2.0-text-to-video",
"prompt": "一只金毛巡回犬穿越阳光洒落的草地,电影级慢动作",
"duration": 5,
"quality": "720p",
"aspect_ratio": "16:9"
}
)
task = response.json()
print(f"Task ID: {task['id']}")
print(f"Status: {task['status']}")
响应(HTTP 200)
{
"id": "task-unified-1774857405-abc123",
"object": "video.generation.task",
"created": 1774857405,
"model": "seedance-2.0-text-to-video",
"status": "pending",
"progress": 0,
"type": "video",
"task_info": {
"can_cancel": true,
"estimated_time": 165,
"video_duration": 5
},
"usage": {
"billing_rule": "per_second",
"credits_reserved": 50,
"user_group": "default"
}
}
注意 billing_rule 固定为 per_second(按秒计费)—— duration 越长,费用越高。
第 4 步:轮询获取视频
所有生成请求都是异步的。使用任务 ID 轮询结果:
import time
task_id = task["id"]
while True:
status = requests.get(
f"https://api.evolink.ai/v1/tasks/{task_id}",
headers={"Authorization": f"Bearer {os.environ['EVOLINK_API_KEY']}"}
)
result = status.json()
if result["status"] == "completed":
print(f"Video URL: {result['results'][0]}")
break
if result["status"] == "failed":
print("Generation failed")
break
print(f"Progress: {result['progress']}%")
time.sleep(5)
重要: 生成的视频链接 有效期 24 小时。请及时下载并保存到你自己的存储。
生产环境建议使用 Webhooks(callback_url)替代轮询。
常见陷阱
| 症状 | 原因 | 解决 |
|---|---|---|
400 invalid_request,参数名是 model | 你写了 "model": "seedance-2.0" | 必须使用完整 model ID,如 seedance-2.0-text-to-video |
传了 image_urls 但报错 | text-to-video 不接受图片输入 | 改用 seedance-2.0-image-to-video |
quality: "1080p" 被拒 | 本 API 不支持 1080p | 改用 480p 或 720p |
| 单图 > 30MB 或 > 6000px 被拒 | 超出图片输入限制 | 先压缩到允许范围(详见 image-to-video) |