> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elkapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 创建 Seedance 视频

> <ul><li>通过 ElkAPI 调用 Doubao Seedance 2.0 视频生成。</li><li>异步任务接口，提交后返回任务 ID。</li><li>Seedance 官方参数请放在 metadata 中转发。</li></ul>

<RequestExample>
  ```bash cURL theme={null} theme={null}
  curl --request POST \
    --url 'https://api.elkapi.com/v1/video/generations' \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "doubao-seedance-2-0-260128",
      "prompt": "第一人称视角果茶宣传广告，手摘苹果、鲜切现摇、成品特写，电影感，高细节",
      "metadata": {
        "duration": 8,
        "ratio": "16:9",
        "resolution": "720p",
        "generate_audio": true,
        "watermark": false
      }
    }'
  ```

  ```python Python theme={null} theme={null}
  import requests

  url = "https://api.elkapi.com/v1/video/generations"
  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }
  payload = {
      "model": "doubao-seedance-2-0-260128",
      "prompt": "第一人称视角果茶宣传广告，手摘苹果、鲜切现摇、成品特写，电影感，高细节",
      "metadata": {
          "duration": 8,
          "ratio": "16:9",
          "resolution": "720p",
          "generate_audio": True,
          "watermark": False
      }
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.json())
  ```

  ```javascript JavaScript theme={null} theme={null}
  const response = await fetch("https://api.elkapi.com/v1/video/generations", {
    method: "POST",
    headers: {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "doubao-seedance-2-0-260128",
      prompt: "第一人称视角果茶宣传广告，手摘苹果、鲜切现摇、成品特写，电影感，高细节",
      metadata: {
        duration: 8,
        ratio: "16:9",
        resolution: "720p",
        generate_audio: true,
        watermark: false
      }
    })
  });

  console.log(await response.json());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null} theme={null}
  {
    "id": "task_abc123",
    "task_id": "task_abc123",
    "object": "video",
    "model": "doubao-seedance-2-0-260128",
    "status": "queued",
    "progress": 0,
    "created_at": 1760000000
  }
  ```

  ```json 400 theme={null} theme={null}
  {
    "error": {
      "message": "prompt is required",
      "type": "invalid_request_error",
      "param": "prompt",
      "code": "invalid_request"
    }
  }
  ```
</ResponseExample>

## Authorizations

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用 Bearer Token 进行认证。

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="model" type="string" required default="doubao-seedance-2-0-260128">
  Seedance 模型 ID。

  可用值：`doubao-seedance-2-0-260128`、`doubao-seedance-2-0-fast-260128`
</ParamField>

<ParamField body="prompt" type="string" required>
  文本提示词。当前适配器会把该字段作为最终的 `content` 文本条目发送给上游。
</ParamField>

<ParamField body="images" type="array<string>">
  图片 URL 或 Base64 数组。需要指定 `role` 时，建议改用 `metadata.content`。
</ParamField>

<ParamField body="seconds" type="string">
  视频时长秒数。填写后会覆盖 `metadata.duration`。
</ParamField>

<ParamField body="metadata" type="object">
  透传给 Seedance 上游的参数对象。Seedance 官方字段请放在这里。
</ParamField>

<ParamField body="metadata.duration" type="integer">
  视频时长，Seedance 2.0 通常为 `4` 到 `15` 秒，也可按上游支持传 `-1`。
</ParamField>

<ParamField body="metadata.ratio" type="string">
  视频比例。

  示例：`16:9`、`4:3`、`1:1`、`3:4`、`9:16`、`21:9`、`adaptive`
</ParamField>

<ParamField body="metadata.resolution" type="string">
  分辨率。

  示例：`480p`、`720p`、`1080p`
</ParamField>

<ParamField body="metadata.generate_audio" type="boolean">
  是否生成音频。
</ParamField>

<ParamField body="metadata.watermark" type="boolean">
  是否添加水印。
</ParamField>

<ParamField body="metadata.seed" type="integer">
  随机种子。
</ParamField>

<ParamField body="metadata.content" type="array<object>">
  多模态参考内容。支持 `image_url`、`video_url`、`audio_url`；文本内容请使用顶层 `prompt`。

  ```json theme={null}
  [
    {
      "type": "image_url",
      "image_url": {
        "url": "https://example.com/reference.png"
      },
      "role": "reference_image"
    },
    {
      "type": "video_url",
      "video_url": {
        "url": "https://example.com/reference.mp4"
      },
      "role": "reference_video"
    },
    {
      "type": "audio_url",
      "audio_url": {
        "url": "https://example.com/reference.mp3"
      },
      "role": "reference_audio"
    }
  ]
  ```
</ParamField>

## 多模态示例

<RequestExample>
  ```bash cURL theme={null} theme={null}
  curl --request POST \
    --url 'https://api.elkapi.com/v1/video/generations' \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "doubao-seedance-2-0-260128",
      "prompt": "全程使用参考视频的第一视角构图，使用参考音频作为背景音乐，生成果茶宣传广告",
      "metadata": {
        "duration": 11,
        "ratio": "16:9",
        "generate_audio": true,
        "watermark": false,
        "content": [
          {
            "type": "image_url",
            "image_url": {
              "url": "https://example.com/first-frame.jpg"
            },
            "role": "reference_image"
          },
          {
            "type": "video_url",
            "video_url": {
              "url": "https://example.com/reference.mp4"
            },
            "role": "reference_video"
          },
          {
            "type": "audio_url",
            "audio_url": {
              "url": "https://example.com/music.mp3"
            },
            "role": "reference_audio"
          }
        ]
      }
    }'
  ```
</RequestExample>

## Response

<ResponseField name="id" type="string">
  ElkAPI 返回的公开任务 ID。
</ResponseField>

<ResponseField name="task_id" type="string">
  兼容字段，值与 `id` 一致。
</ResponseField>

<ResponseField name="object" type="string">
  对象类型，固定为 `video`。
</ResponseField>

<ResponseField name="model" type="string">
  请求使用的模型。
</ResponseField>

<ResponseField name="status" type="string">
  任务状态。提交成功后通常为 `queued`。
</ResponseField>

<ResponseField name="created_at" type="integer">
  任务创建时间戳。
</ResponseField>
