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

# getGenerateVideosOperation

> 查询视频生成任务的状态和结果。

查询长时间运行的视频生成任务的状态和结果。

当原始视频模型名称包含 `/` 时，operation resource name 会保留完整模型标识，例如
`.../models/google/veo-3.1-generate-preview/operations/{operation_id}`。

完成后的响应同时保留两套兼容字段：已有客户可以继续读取
`response.generatedVideos`，Google 官方 SDK 读取
`response.generateVideoResponse.generatedSamples[].video`。新增 Google SDK 字段不会删除、
重命名或重组已有 TokenOps 响应字段。

官方 Google SDK 可以直接轮询这个 GET 接口。即使 SDK 为 GET 请求保留
`Content-Type: application/json` 且不发送 body，Router 也会正常处理，无需客户删除该请求头。


## OpenAPI

````yaml GET /v1beta/projects/{project_id}/locations/{location}/publishers/{publisher}/models/{model}/operations/{operation_id}
openapi: 3.1.0
info:
  title: TokenOps AI API
  description: TokenOps AI API 提供了强大的AI服务能力，包括聊天对话、Gemini模型集成等功能。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tokenops.ai
    description: TokenOps AI API 生产环境
security: []
paths:
  /v1beta/projects/{project_id}/locations/{location}/publishers/{publisher}/models/{model}/operations/{operation_id}:
    get:
      summary: 获取视频生成操作状态
      description: 查询视频生成任务的状态和结果。
      operationId: getGenerateVideosOperation
      parameters:
        - name: project_id
          in: path
          required: true
          description: 项目ID
          schema:
            type: string
            example: my-project
        - name: location
          in: path
          required: true
          description: 地理位置
          schema:
            type: string
            example: us-central1
        - name: publisher
          in: path
          required: true
          description: 发布者
          schema:
            type: string
            example: google
        - name: model
          in: path
          required: true
          description: 完整 TokenOps 模型名称；可包含斜杠分段，例如 google/veo-3.1-generate-preview。
          schema:
            type: string
            example: veo-3.1-generate-preview
        - name: operation_id
          in: path
          required: true
          description: 操作ID，从predictLongRunning接口返回的操作名称中提取
          schema:
            type: string
            example: >-
              projects/my-project/locations/us-central1/operations/operation-123456789
      responses:
        '200':
          description: 成功获取操作状态
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateVideosOperation'
              examples:
                operation_completed:
                  summary: 视频生成完成
                  value:
                    name: >-
                      projects/my-project/locations/global/publishers/google/models/veo-3.1-fast-generate-001/operations/operation-123456789
                    done: true
                    response:
                      generatedVideos:
                        - uri: https://my-bucket/generated-videos/video-123.mp4
                          videoBytes: aSDinaTvuI8gbWludGxpZnk=
                          mimeType: video/mp4
                          createTime: '2026-07-15T00:00:00Z'
                      generateVideoResponse:
                        generatedSamples:
                          - video:
                              uri: >-
                                https://generativelanguage.googleapis.com/v1beta/files/video-123
                              encodedVideo: aSDinaTvuI8gbWludGxpZnk=
                              encoding: video/mp4
                            encoding: video/mp4
        '400':
          description: 客户端错误（包括操作不存在、权限不足等）
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    GenerateVideosOperation:
      type: object
      properties:
        name:
          type: string
          description: 操作名称
          example: >-
            projects/my-project/locations/us-central1/operations/operation-123456789
        metadata:
          type: object
          description: 操作元数据
          additionalProperties: true
        done:
          type: boolean
          description: 操作是否完成
          example: false
        error:
          $ref: '#/components/schemas/Status'
          description: 错误信息（如果操作失败）
        response:
          $ref: '#/components/schemas/GenerateVideosResponse'
          description: 视频生成响应（如果操作成功完成）
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Status'
          description: 错误信息
    Status:
      type: object
      properties:
        code:
          type: integer
          description: 错误代码
        message:
          type: string
          description: 错误消息
        details:
          type: array
          description: 错误详情
          items:
            type: object
            additionalProperties: true
    GenerateVideosResponse:
      type: object
      properties:
        generatedVideos:
          type: array
          description: TokenOps 既有视频结果字段；为向后兼容保留
          items:
            $ref: '#/components/schemas/GeneratedVideo'
        generateVideoResponse:
          $ref: '#/components/schemas/GenerateVideoResponse'
          description: 供 Google 官方 SDK 直接解析的 Gemini API 视频生成结果
    GeneratedVideo:
      type: object
      properties:
        uri:
          type: string
          description: 生成视频的URI（当视频存储在云存储时返回）
          example: https://my-bucket/generated-videos/video-123.mp4
        videoBytes:
          type: string
          description: Base64编码的视频数据（当视频以内联方式返回时）
          format: byte
        mimeType:
          type: string
          description: 视频的MIME类型
          example: video/mp4
        createTime:
          type: string
          format: date-time
          description: 创建时间
      description: 生成的视频可以通过URI访问或直接包含base64编码的视频数据
    GenerateVideoResponse:
      type: object
      properties:
        generatedSamples:
          type: array
          description: Google Gemini API 生成的视频样本
          items:
            $ref: '#/components/schemas/GeneratedVideoSample'
    GeneratedVideoSample:
      type: object
      properties:
        video:
          $ref: '#/components/schemas/GoogleGeneratedVideo'
          description: 生成的视频
        encoding:
          type: string
          description: 视频的 MIME 类型
          example: video/mp4
    GoogleGeneratedVideo:
      type: object
      properties:
        uri:
          type: string
          description: Google Gemini API 视频下载 URI
          example: https://generativelanguage.googleapis.com/v1beta/files/video-123
        encodedVideo:
          type: string
          description: Google Gemini API Base64 编码视频数据
          format: byte
        encoding:
          type: string
          description: 视频的 MIME 类型
          example: video/mp4
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      description: >-
        TokenOPS.AI API密钥认证。在 `Authorization` HTTP Header 中包含您的 API-Key，格式为
        `Bearer {API_KEY}`

````