> ## 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.

# 创建视频 · OpenAI 视频

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

已有 OpenAI SDK `client.videos` 集成时使用这个格式。支持文生视频和单张首帧图生视频，输出 720p。参考音频、多张参考图和视频编辑请使用 [Ark / Seedance](/cn/api/video-ark)。

## 接入配置

OpenAI SDK 的 Base URL 填 `https://api.aiohub.org/v1`，API key 填完整的 AIOHub `sk-` API 令牌。这是视频接口，不使用 Chat Completions 或 Responses。

## 请求示例

把 `<AIOHUB_API_KEY>` 替换为完整 API 令牌。所选分组需包含示例中的 Seedance 模型。

```bash theme={"system"}
curl https://api.aiohub.org/v1/videos \
  -H "Authorization: Bearer <AIOHUB_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedance-2-5-260628",
    "prompt": "A blue ceramic cup on a wooden table in daylight.",
    "seconds": "4",
    "size": "1280x720"
  }'
```

创建响应的关键字段如下。保存 `id`，不要再次提交创建请求来查询进度。

```json theme={"system"}
{"id": "task_example", "object": "video", "status": "queued", "progress": 0}
```

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

## 参数范围

JSON 请求使用 `application/json`；上传图片文件时使用 `multipart/form-data`，文件字段为 `input_reference`。尺寸不匹配时先裁剪或缩放图片再提交。

<Accordion title="SDK 完整示例">
  安装 `openai` SDK，并在运行环境中设置 `AIOHUB_API_KEY`。示例只在生成成功后下载。

  <CodeGroup>
    ```python Python theme={"system"}
    import os
    from openai import OpenAI

    client = OpenAI(api_key=os.environ["AIOHUB_API_KEY"], base_url="https://api.aiohub.org/v1")

    video = client.videos.create(
        model="doubao-seedance-2-5-260628",
        prompt="木桌上的蓝色陶瓷杯，自然光，镜头缓慢推进。",
        seconds="4",
        size="1280x720",
    )
    video = client.videos.poll(video.id)
    if video.status != "completed":
        raise RuntimeError(f"Video generation failed: {video.error}")
    with open("video.mp4", "wb") as f:
        f.write(client.videos.download_content(video.id).read())
    ```

    ```typescript TypeScript theme={"system"}
    import OpenAI from "openai";

    const client = new OpenAI({ apiKey: process.env.AIOHUB_API_KEY, baseURL: "https://api.aiohub.org/v1" });

    let video = await client.videos.create({
      model: "doubao-seedance-2-5-260628",
      prompt: "木桌上的蓝色陶瓷杯，自然光，镜头缓慢推进。",
      seconds: "4",
      size: "1280x720",
    });
    while (video.status !== "completed" && video.status !== "failed") {
      await new Promise((r) => setTimeout(r, 15000));
      video = await client.videos.retrieve(video.id);
    }
    if (video.status !== "completed") {
      throw new Error(JSON.stringify(video.error));
    }
    const bytes = await (await client.videos.downloadContent(video.id)).arrayBuffer();
    ```
  </CodeGroup>
</Accordion>

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


## OpenAPI

````yaml openapi/relay.json POST /v1/videos
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/videos:
    post:
      tags:
        - 视频生成
      summary: 创建视频
      description: >
        OpenAI 兼容的视频生成接口，可直接使用 OpenAI SDK 的 `videos` 客户端。


        Seedance 模型通过该接口生成 720p 视频：`seconds` 取 `"4"`、`"8"` 或 `"12"`（默认
        `"4"`），`size` 取 `"1280x720"` 或 `"720x1280"`（默认），`input_reference`
        可选，作为首帧图片，像素尺寸必须与 `size` 一致。需要参考图、音频、视频编辑、1080p/4k、更长时长或固定画面比例时，使用
        [创建视频任务](/cn/api/video-ark) 中的任务接口。


        参考文档: https://platform.openai.com/docs/api-reference/videos/create
      operationId: createVideo
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                model:
                  type: string
                  example: doubao-seedance-2-5-260628
                  description: 模型名称
                prompt:
                  type: string
                  example: >-
                    A blue ceramic cup on a wooden table in daylight, slow
                    camera push-in.
                  description: 提示词
                seconds:
                  type: string
                  example: '4'
                  description: 生成秒数
                size:
                  type: string
                  example: 1280x720
                  description: 视频尺寸
                input_reference:
                  type: string
                  example: https://example.com/first.png
                  description: 首帧图片的 HTTPS 地址或 data URL
            examples:
              text:
                summary: 文生视频
                value:
                  model: doubao-seedance-2-5-260628
                  prompt: A blue ceramic cup on a wooden table in daylight.
                  seconds: '4'
                  size: 1280x720
          multipart/form-data:
            schema:
              type: object
              properties:
                model:
                  type: string
                  example: doubao-seedance-2-5-260628
                  description: 模型名称
                prompt:
                  description: 提示词
                  example: cute cat dance
                  type: string
                seconds:
                  type: string
                  example: '4'
                  description: 生成秒数
                input_reference:
                  format: binary
                  type: string
                  description: 参考图片文件
                  example: ''
                size:
                  type: string
                  example: 1280x720
                  description: 视频尺寸。Seedance 模型支持 `1280x720` 和 `720x1280`。
            examples: {}
      responses:
        '200':
          description: 成功创建视频任务
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: 视频 ID
                  object:
                    type: string
                    description: 对象类型
                  model:
                    type: string
                    description: 使用的模型
                  status:
                    type: string
                    description: 任务状态
                  progress:
                    type: integer
                    description: 进度百分比
                  created_at:
                    type: integer
                    description: 创建时间戳
                  seconds:
                    type: string
                    description: 视频时长
                  completed_at:
                    type: integer
                    description: 完成时间戳
                  expires_at:
                    type: integer
                    description: 过期时间戳
                  size:
                    type: string
                    description: 视频尺寸
                  error:
                    $ref: '#/components/schemas/OpenAIVideoError'
                  metadata:
                    type: object
                    description: 额外元数据
                    additionalProperties: true
                    properties: {}
                required:
                  - id
                  - object
                  - model
                  - status
                  - progress
                  - created_at
                  - seconds
              example:
                id: task_ADQ5XK6AKWg36WePoJ3sZRyDvWl1ogGZ
                object: video
                model: doubao-seedance-2-5-260628
                status: queued
                progress: 0
                created_at: 1791275108
                seconds: '4'
                size: 1280x720
          headers: {}
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          headers: {}
      deprecated: false
      security:
        - BearerAuth: []
components:
  schemas:
    OpenAIVideoError:
      type: object
      description: OpenAI 视频错误信息
      properties:
        message:
          type: string
          description: 错误信息
        code:
          type: string
          description: 错误码
    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
  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.