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

# 查询视频 · Vertex AI

> 查询任务状态、判断成功或失败，并获取视频下载地址。

## 查询与状态判断

把 `<OPERATION_NAME>` 替换为创建响应的完整 `name`，每 10 到 15 秒查询一次：

```bash theme={"system"}
curl "https://api.aiohub.org/v1/publishers/bytedance/models/doubao-seedance-2-5-260628:fetchPredictOperation" \
  -H "Authorization: Bearer <AIOHUB_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"operationName": "<OPERATION_NAME>"}'
```

| 响应 | 处理 |
| - | - |
| `done: false` | 继续查询 |
| `done: true` 且包含 `response` | 下载视频 |
| `done: true` 且包含 `error` | 停止查询，读取 `error.message` |

`done: true` 只表示任务结束，不代表成功。

## 读取成功结果

成功响应的关键字段：

```json theme={"system"}
{
  "name": "publishers/bytedance/models/doubao-seedance-2-5-260628/operations/task_example",
  "done": true,
  "response": {
    "videos": [
      {
        "gcsUri": "https://api.aiohub.org/v1/videos/task_example/content",
        "mimeType": "video/mp4"
      }
    ]
  }
}
```

`response.videos[0].gcsUri` 是 AIOHub 的 HTTPS 地址，不是 `gs://` 对象。用 HTTP 客户端下载，无需配置 Google Cloud Storage。

任务成功后，按 [下载视频](/cn/api/video-content) 保存文件。

## 失败与重试

查询断线后用原 `name` 继续查询，不要重新调用 `predictLongRunning`。收到 400 时先修正字段；任务结束后若有 `error`，不要读取成功结果字段。视频文件保留 72 小时，任务记录保留 7 天。

收到 429 或临时不可用错误时，等待后重试查询，不要重新创建任务。查询不到任务时，确认任务标识和 API 令牌所属账号。


## OpenAPI

````yaml openapi/relay.json POST /v1/publishers/{publisher}/models/{model}:fetchPredictOperation
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/publishers/{publisher}/models/{model}:fetchPredictOperation:
    post:
      tags:
        - 视频生成
      summary: 查询 Vertex 视频任务
      description: >
        done: false 时继续查询。done: true 时先检查 error；有 error 时读取 error.message，成功时再读取
        response。任务记录可查询 7 天。


        从 response.videos[0].gcsUri 下载视频，该值是带鉴权的 HTTPS 地址。
      operationId: getSeedanceVertexVideo
      parameters:
        - name: publisher
          in: path
          required: true
          description: 模型发布者，Seedance 示例使用 bytedance。
          schema:
            type: string
            example: bytedance
          example: bytedance
        - name: model
          in: path
          required: true
          description: 完整 Seedance 模型名。
          schema:
            type: string
            example: doubao-seedance-2-5-260628
          example: doubao-seedance-2-5-260628
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                operationName:
                  type: string
                  description: 创建响应中的完整 name，原样传入。
              required:
                - operationName
            example:
              operationName: >-
                publishers/bytedance/models/doubao-seedance-2-5-260628/operations/task_example
      responses:
        '200':
          description: 当前任务状态；生成失败也可能返回 HTTP 200。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeedanceVertexOperation'
              examples:
                pending:
                  summary: 处理中
                  value:
                    name: >-
                      publishers/bytedance/models/doubao-seedance-2-5-260628/operations/task_example
                    done: false
                succeeded:
                  summary: 生成成功
                  value:
                    name: >-
                      publishers/bytedance/models/doubao-seedance-2-5-260628/operations/task_example
                    done: true
                    response:
                      videos:
                        - gcsUri: >-
                            https://api.aiohub.org/v1/videos/task_example/content
                          mimeType: video/mp4
                failed:
                  summary: 生成失败
                  value:
                    name: >-
                      publishers/bytedance/models/doubao-seedance-2-5-260628/operations/task_example
                    done: true
                    error:
                      message: Video generation failed
        '400':
          description: 字段、类型或模型能力不匹配。根据 code 和 message 修正后重试。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeedanceTaskError'
        '401':
          description: API 令牌缺失或无效。
        '404':
          description: 任务不存在或不属于当前账号。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeedanceTaskError'
      security:
        - BearerAuth: []
components:
  schemas:
    SeedanceVertexOperation:
      type: object
      properties:
        name:
          type: string
          description: 完整 operation name。保存原值用于后续查询。
        done:
          type: boolean
          description: false 表示等待；true 表示已结束，但可能是失败，须检查 error。
        response:
          type: object
          properties:
            '@type':
              type: string
              description: 响应类型。
            videos:
              type: array
              items:
                type: object
                properties:
                  gcsUri:
                    type: string
                    description: AIOHub HTTPS 下载地址，不是 gs:// 对象；下载需要 API 令牌。
                    format: uri
                  mimeType:
                    type: string
                    enum:
                      - video/mp4
                required:
                  - gcsUri
                  - mimeType
        error:
          type: object
          properties:
            message:
              type: string
              description: 生成失败原因。
          required:
            - message
      required:
        - name
        - done
    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
  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.