跳转至

Seedance 视频 API

支持 Seedance 2.0、Fast、Mini 和 2.5。先创建任务,拿到 task_id 后查询状态,再下载视频。

基本信息

项目 说明
API 地址 https://api.jarlessapi.com
认证方式 Authorization: Bearer <api_key>
创建任务 POST /v1/videos/tasks

以下示例在 Bash 终端中执行,将 API_KEY 替换为你的密钥。

export API_HOST="https://api.jarlessapi.com"
export API_KEY="你的 API Key"

可用模型

seedance-2.0
seedance-2.0-fast
seedance-2.0-mini
seedance-2.5

文生视频

curl -X POST "$API_HOST/v1/videos/tasks" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: video-demo-001" \
  -d '{
    "action": "text_to_video",
    "model": "seedance-2.0-mini",
    "inputs": [
      {
        "role": "prompt",
        "type": "text",
        "content": "一段自然风景视频,镜头缓慢向前推进"
      }
    ],
    "output": {
      "duration": 4,
      "aspect_ratio": "16:9",
      "size": "480p"
    }
  }'

创建成功后保存响应中的 task_id:

{
  "task_id": "gen_0123456789abcdef",
  "status": "running"
}

创建示例均包含 Idempotency-Key。每次新建任务时换一个值,同一次请求重试时沿用原值。

素材地址

有自己的公网素材 URL 时,可以直接用于生成,不需要再次上传。URL 需要满足:

  • 使用公网 HTTP(S) 地址,推荐 HTTPS。
  • 无需登录、Cookie 或特殊请求头即可下载。
  • 不限制服务端下载,不启用防盗链。
  • 直接返回图片、视频或音频文件,不能返回网页。
  • 不支持内网地址、localhost、Base64 和 data: URL。

没有公网 URL 时,可以先把本地素材上传到 JarlessAPI:

curl -X POST "$API_HOST/v1/uploads" \
  -H "Authorization: Bearer $API_KEY" \
  -F "file=@./input.jpg"

响应中的 url 就是可用于生成的临时公网地址:

{
  "id": "upload_xxx.jpg",
  "status": "ready",
  "url": "https://api.jarlessapi.com/v1/uploads/upload_xxx.jpg/content?expires=...&signature=..."
}

上传和创建任务需要使用同一账号所属的 API Key,并在 URL 过期前提交任务。

图生视频

将示例中的 url 替换为你的公网图片地址,或上传接口返回的 url:

curl -X POST "$API_HOST/v1/videos/tasks" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: video-demo-002" \
  -d '{
    "action": "image_to_video",
    "model": "seedance-2.5",
    "inputs": [
      {
        "role": "prompt",
        "type": "text",
        "content": "让画面自然动起来,镜头缓慢向前推进"
      },
      {
        "role": "image",
        "type": "url",
        "url": "https://example.com/input.jpg",
        "mime_type": "image/jpeg"
      }
    ],
    "output": {
      "duration": 4,
      "aspect_ratio": "16:9",
      "size": "480p"
    }
  }'

多素材参考

图片、视频和音频都可以直接使用公网地址,也可以分别上传后使用返回的 url:

curl -X POST "$API_HOST/v1/videos/tasks" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: video-demo-003" \
  -d '{
    "action": "reference_to_video",
    "model": "seedance-2.5",
    "inputs": [
      {"role": "prompt", "type": "text", "content": "参考 @image_file_1、@video_file_1 和 @audio_file_1 生成视频"},
      {"role": "reference_image", "type": "url", "url": "https://example.com/image.jpg", "mime_type": "image/jpeg"},
      {"role": "reference_video", "type": "url", "url": "https://example.com/video.mp4", "mime_type": "video/mp4"},
      {"role": "reference_audio", "type": "url", "url": "https://example.com/audio.mp3", "mime_type": "audio/mpeg"}
    ],
    "output": {
      "duration": 5,
      "aspect_ratio": "16:9",
      "size": "720p"
    },
    "params": {
      "generate_audio": true
    }
  }'

查询任务

将下面的 gen_0123456789abcdef 替换为创建响应中的 task_id。

curl "$API_HOST/v1/videos/tasks/gen_0123456789abcdef" \
  -H "Authorization: Bearer $API_KEY"

任务状态通常为 submitted、running、succeeded 或 failed。失败时查看响应中的 error.code 和 error.message。

下载视频

任务状态变为 succeeded 后,将路径中的任务 ID 替换为你的 task_id,再下载:

curl -L "$API_HOST/v1/videos/tasks/gen_0123456789abcdef/content" \
  -H "Authorization: Bearer $API_KEY" \
  -o result.mp4

生成结果有保留期限,请在任务完成后及时下载。

其他视频入口见 Grok 生视频 API。