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

# 查询视频 · Gemini API

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

## 查询与状态判断

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

```bash theme={"system"}
curl "https://api.aiohub.org/v1beta/<OPERATION_NAME>" \
  -H "Authorization: Bearer <AIOHUB_API_KEY>"
```

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

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

## 读取成功结果

成功响应的关键字段：

```json theme={"system"}
{
  "name": "models/doubao-seedance-2-5-260628/operations/task_example",
  "done": true,
  "response": {
    "generateVideoResponse": {
      "generatedSamples": [
        {
          "video": {
            "uri": "https://api.aiohub.org/v1beta/files/<FILE_NAME>:download?alt=media"
          }
        }
      ]
    }
  }
}
```

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

## 失败与重试

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

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


## OpenAPI

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


        从 response.generateVideoResponse.generatedSamples[0].video.uri
        下载视频，保留完整地址。
      operationId: getSeedanceGeminiVideo
      parameters:
        - name: model
          in: path
          required: true
          description: 完整 Seedance 模型名。
          schema:
            type: string
            example: doubao-seedance-2-5-260628
          example: doubao-seedance-2-5-260628
        - name: operation
          in: path
          required: true
          description: 创建响应 name 中 operations/ 后的任务标识，不是完整 name。
          schema:
            type: string
            example: task_example
          example: task_example
      responses:
        '200':
          description: 当前任务状态；生成失败也可能返回 HTTP 200。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeedanceGeminiOperation'
              examples:
                pending:
                  summary: 处理中
                  value:
                    name: models/doubao-seedance-2-5-260628/operations/task_example
                    done: false
                succeeded:
                  summary: 生成成功
                  value:
                    name: models/doubao-seedance-2-5-260628/operations/task_example
                    done: true
                    response:
                      generateVideoResponse:
                        generatedSamples:
                          - video:
                              uri: >-
                                https://api.aiohub.org/v1beta/files/7461736b5f6578616d706c65:download?alt=media
                failed:
                  summary: 生成失败
                  value:
                    name: 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:
    SeedanceGeminiOperation:
      type: object
      properties:
        name:
          type: string
          description: 完整 operation name。保存原值用于后续查询。
        done:
          type: boolean
          description: false 表示等待；true 表示已结束，但可能是失败，须检查 error。
        response:
          type: object
          properties:
            '@type':
              type: string
              description: 响应类型。
            generateVideoResponse:
              type: object
              properties:
                generatedSamples:
                  type: array
                  items:
                    type: object
                    properties:
                      video:
                        type: object
                        properties:
                          uri:
                            type: string
                            description: 成功后返回的完整 HTTPS 文件下载地址；下载需要 API 令牌。
                            format: uri
                        required:
                          - uri
                    required:
                      - video
        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.