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

# 创建视频 · Ark / Seedance

> 使用 Ark / Seedance 格式提交 Seedance 视频任务，查看示例、输入限制和完整参数。

新接入，或需要参考音频、参考视频、视频编辑时，使用这个格式。模型和价格见 [视频模型与计费](/cn/api/video-models)。

## 接入配置

服务地址是 `https://api.aiohub.org`。所有请求携带 `Authorization: Bearer <AIOHUB_API_KEY>`，把占位符替换为完整的 `sk-` API 令牌，令牌分组需能访问所选模型。

## 请求示例

最小请求只需提示词，不需要先准备图片。

```bash theme={"system"}
curl https://api.aiohub.org/v1/contents/generations/tasks \
  -H "Authorization: Bearer <AIOHUB_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedance-2-5-260628",
    "content": [{"type": "text", "text": "A blue ceramic cup on a wooden table in daylight."}],
    "resolution": "720p",
    "ratio": "16:9",
    "duration": 5
  }'
```

创建成功返回 `id`，保存它用于后续查询。此时任务尚未完成。

```json theme={"system"}
{"id": "task_example"}
```

拿到任务标识后，转到 [查询任务](/cn/api/video-ark-get)。

## 图片、音频与视频输入

Ark / Seedance 任务接口的请求体用 `content[]` 数组携带提示词和参考媒体，每个媒体项通过 `role` 说明用途：

| 媒体类型 | `role` 取值 |
| - | - |
| `image_url` | `first_frame`（省略时默认）、`last_frame`、`reference_image` |
| `video_url` | `reference_video` |
| `audio_url` | `reference_audio` |

媒体 `url` 填 HTTPS 地址；图片和音频也可以用 base64 data URL（如 `data:image/png;base64,...`）。单个媒体最大 100 MB。

| 输入组合 | 2.5 | 2.0、2.0 fast、2.0 mini |
| - | - | - |
| 仅文本 | 支持 | 支持 |
| 一张 `first_frame` 图片 | 支持，任意比例 | 支持，任意比例 |
| `first_frame` + `last_frame` | 支持，`ratio: adaptive` | 支持，任意比例 |
| 仅 `reference_image` | 1 到 30 张 | 1 到 9 张 |
| 参考图搭配参考视频或音频 | 最多 30 张图、10 段视频、10 段音频 | 最多 9 张图、3 段视频、3 段音频 |
| 仅 `reference_audio` | 1 到 10 段 | |
| 视频编辑（`omni_reference_task_type: "edit"`） | 一段 `reference_video`，`ratio: adaptive`，`duration: -1` | |

与视频或音频一起提交的图片需要 `role: reference_image`。参考视频和音频在 2.5 上每段 2 到 30 秒、合计 30 秒以内；在 2.0 系列上每段 2 到 15 秒、合计 15 秒以内。视频编辑的源视频 4 到 30 秒，输出时长与源视频相同。

## 状态回调

创建时填写 `callback_url`，AIOHub 会在任务状态变化时把任务对象 POST 到该地址，请求头带 `User-Agent: AIOHub-LibTV-Callback/1`。请在 5 秒内返回 2xx，否则最多重试三次。

<Note>创建请求超时且未拿到任务标识时，先检查 [用量日志](https://api.aiohub.org/console/log)，避免重复生成和扣费。400 错误需要先修正参数；401 错误请检查令牌。模型权限和额度见 [鉴权](/cn/api/authentication)。</Note>


## OpenAPI

````yaml openapi/relay.json POST /v1/contents/generations/tasks
openapi: 3.0.1
info:
  title: AIOHub API
  description: AIOHub 公开 API
  version: 1.0.0
servers:
  - url: https://api.aiohub.org
security:
  - BearerAuth: []
tags:
  - name: 获取模型列表
  - name: OpenAI Chat
  - name: OpenAI Responses
  - name: 图片生成
  - name: OpenAI 图像
  - name: 视频生成
  - name: Claude Messages
  - name: Gemini API
  - name: OpenAI Embeddings
  - name: 文本补全
  - name: OpenAI 音频
  - name: Realtime API
paths:
  /v1/contents/generations/tasks:
    post:
      tags:
        - 视频生成
      summary: 创建视频任务
      description: |
        提交 Seedance 视频生成任务，返回任务 ID。任务异步执行，之后用任务 ID 查询状态并下载结果。

        模型、分辨率、时长、输入组合和计费规则见 [视频模型与计费](/cn/api/video-models)。请求校验失败返回 400，不产生费用。
      operationId: createSeedanceVideoTask
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SeedanceCreateTaskRequest'
            examples:
              text:
                summary: 文生视频
                value:
                  model: doubao-seedance-2-5-260628
                  content:
                    - type: text
                      text: >-
                        A blue ceramic cup on a wooden table in daylight, slow
                        camera push-in.
                  resolution: 720p
                  ratio: '16:9'
                  duration: 5
              first_frame:
                summary: 首帧图生视频
                value:
                  model: doubao-seedance-2-5-260628
                  content:
                    - type: text
                      text: >-
                        A blue ceramic cup on a wooden table in daylight, slow
                        camera push-in.
                    - type: image_url
                      image_url:
                        url: https://example.com/first.png
                      role: first_frame
                  resolution: 720p
                  ratio: adaptive
                  duration: 5
                  generate_audio: true
              reference:
                summary: 参考图和参考音频
                value:
                  model: doubao-seedance-2-5-260628
                  content:
                    - type: text
                      text: >-
                        A blue ceramic cup on a wooden table in daylight, slow
                        camera push-in.
                    - type: image_url
                      image_url:
                        url: https://example.com/style.png
                      role: reference_image
                    - type: audio_url
                      audio_url:
                        url: https://example.com/voice.wav
                      role: reference_audio
                  resolution: 1080p
                  duration: 8
      responses:
        '200':
          description: 任务已创建
          headers: {}
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: 任务 ID
                required:
                  - id
              example:
                id: task_ADQ5XK6AKWg36WePoJ3sZRyDvWl1ogGZ
        '400':
          description: >-
            请求字段或取值不在支持范围内。`code` 为
            `unsupported_field`、`invalid_request`、`invalid_duration`、`unsupported_resolution`、`unsupported_ratio`、`invalid_media_mode`、`unsupported_media_carrier`
            或 `invalid_media`。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeedanceTaskError'
          headers: {}
        '401':
          description: API 令牌缺失或无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          headers: {}
        '403':
          description: 余额不足
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          headers: {}
        '429':
          description: 上游容量已满，请稍后重试
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          headers: {}
        '503':
          description: API 令牌所在分组没有该模型，检查令牌分组
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          headers: {}
      deprecated: false
      security:
        - BearerAuth: []
components:
  schemas:
    SeedanceCreateTaskRequest:
      type: object
      required:
        - model
        - content
      properties:
        model:
          type: string
          example: doubao-seedance-2-5-260628
          description: 视频模型名称。可用模型和取值范围见 [视频模型与计费](/cn/api/video-models)。
        content:
          type: array
          items:
            $ref: '#/components/schemas/SeedanceContentItem'
          description: 提示词和参考媒体。文生视频只需一个 `text` 项。
        resolution:
          type: string
          enum:
            - 480p
            - 720p
            - 1080p
            - 4k
          default: 720p
          description: 输出分辨率，取值范围随模型不同。
        ratio:
          type: string
          enum:
            - adaptive
            - '16:9'
            - '4:3'
            - '1:1'
            - '3:4'
            - '9:16'
            - '21:9'
          default: adaptive
          description: 画面比例。`adaptive` 由模型根据提示词或输入图片决定。
        duration:
          type: integer
          default: 5
          description: 视频时长，整数秒，取值范围随模型不同。视频编辑任务填 `-1`。
        generate_audio:
          type: boolean
          default: true
          description: 是否生成音频。
        omni_reference_task_type:
          type: string
          enum:
            - auto
            - reference
            - edit
          default: auto
          description: 参考媒体的使用方式。`edit` 以一个 `reference_video` 为源视频做编辑。
        return_last_frame:
          type: boolean
          default: false
          description: 为 `true` 时任务结果包含 `content.last_frame_url`（最后一帧 JPEG）。
        tools:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                enum:
                  - web_search
          description: '填 `[{"type": "web_search"}]` 允许模型在生成时联网搜索。'
        priority:
          type: integer
          minimum: 0
          maximum: 9
          default: 0
          description: 排队优先级，数值越大越早出队；不会打断正在运行的任务。
        callback_url:
          type: string
          format: uri
          description: >-
            公网 HTTPS 地址。任务状态每次变化时，AIOHub 会把任务对象 POST 到该地址，请在 5 秒内返回
            2xx，否则最多重试三次。
        safety_identifier:
          type: string
          maxLength: 64
          description: 稳定的终端用户标识，最长 64 字符，会在任务查询中原样返回。
    SeedanceTaskError:
      type: object
      description: 视频任务接口的错误响应。
      properties:
        code:
          type: string
          description: 错误码
          example: invalid_duration
        message:
          type: string
          description: 错误信息
          example: duration must be between 4 and 30 seconds for this model
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: 错误信息
            type:
              type: string
              description: 错误类型
            param:
              type: string
              description: 相关参数
              nullable: true
            code:
              type: string
              description: 错误代码
              nullable: true
    SeedanceContentItem:
      type: object
      description: '`content[]` 中的一项：文本提示词或参考媒体。'
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - text
            - image_url
            - video_url
            - audio_url
          description: 内容类型。
        text:
          type: string
          description: 提示词，`type` 为 `text` 时必填。多个 `text` 项按换行拼接，总长不超过 20000 字符。
        image_url:
          type: object
          properties:
            url:
              type: string
              description: >-
                HTTPS 地址，或 base64 data URL（如 `data:image/png;base64,...`）。单个媒体最大
                100 MB。
          description: '`type` 为 `image_url` 时必填。'
        video_url:
          type: object
          properties:
            url:
              type: string
              description: 视频的 HTTPS 地址。单个媒体最大 100 MB。
          description: '`type` 为 `video_url` 时必填。'
        audio_url:
          type: object
          properties:
            url:
              type: string
              description: >-
                HTTPS 地址，或 base64 data URL（如 `data:audio/wav;base64,...`）。单个媒体最大
                100 MB。
          description: '`type` 为 `audio_url` 时必填。'
        role:
          type: string
          enum:
            - first_frame
            - last_frame
            - reference_image
            - reference_video
            - reference_audio
          description: >-
            媒体在生成中的角色。图片省略时按 `first_frame` 处理；与视频或音频一起提交的图片需使用
            `reference_image`。视频只能是 `reference_video`，音频只能是 `reference_audio`。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key (sk-xxx)

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.