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

# 创建视频生成并等待结果

> 创建视频任务，并在配置的最大等待时间内等待任务完成。



## OpenAPI

````yaml /zh/openapi.json post /v1/videos/generations/sync
openapi: 3.1.0
info:
  title: APIAny.AI 公开 API
  version: 1.0.0
  description: APIAny.AI 模型聚合、异步媒体任务、对话生成、积分查询和任务查询的公开 API。
servers:
  - url: https://apiany.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Models
    description: 公开模型目录。
  - name: Chat
    description: 文本生成和对话兼容接口。
  - name: Images
    description: 图片生成和图片编辑接口。
  - name: Videos
    description: 视频生成接口。
  - name: Moderation
    description: Image safety and moderation endpoints.
  - name: Tasks
    description: 异步任务查询。
  - name: Account
    description: 账户与积分查询。
  - name: Free APIs
    description: Free utility APIs protected by API key rate limits.
paths:
  /v1/videos/generations/sync:
    post:
      tags:
        - Videos
      summary: 创建视频生成并等待结果
      description: 创建视频任务，并在配置的最大等待时间内等待任务完成。
      operationId: createVideoGenerationSync
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoGenerationRequest'
      responses:
        '200':
          description: 已完成的视频任务。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskResponse'
        '202':
          description: 达到最大等待时间后任务仍在处理中。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AsyncTaskCreateResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
components:
  schemas:
    VideoGenerationRequest:
      type: object
      properties:
        model:
          type: string
          example: seedance-2.0
        prompt:
          type: string
        duration:
          type: string
          example: 10s
        resolution:
          type: string
          example: 720p
        ratio:
          type: string
          example: '16:9'
        input_images:
          type: array
          items:
            type: string
            format: uri
        input_videos:
          type: array
          items:
            type: string
            format: uri
        input_audio:
          type: array
          items:
            type: string
            format: uri
        callback_url:
          type: string
          format: uri
      required:
        - model
        - prompt
    TaskResponse:
      type: object
      properties:
        task_id:
          type: string
          example: task_123
        status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - failed
            - expired
        model:
          type: string
        created_at:
          type: string
          format: date-time
        completed_at:
          type:
            - string
            - 'null'
          format: date-time
        result:
          oneOf:
            - $ref: '#/components/schemas/MediaResult'
            - type: 'null'
        error:
          oneOf:
            - 579952f6-3d5e-484d-8ced-806ab893433c
            - type: 'null'
      required:
        - task_id
        - status
    AsyncTaskCreateResponse:
      type: object
      properties:
        task_id:
          type: string
          example: task_123
        status:
          type: string
          enum:
            - pending
            - processing
        model:
          type: string
        poll_url:
          type: string
          example: /v1/tasks/task_123
      required:
        - task_id
        - status
        - poll_url
    MediaResult:
      description: >-
        已完成任务的结果。图片任务采用 OpenAI 图片格式（图片地址在 data[0].url）；视频与音频任务提供
        video_url/audio_url 以及 urls[] 数组。
      oneOf:
        - $ref: '#/components/schemas/ImageTaskResult'
        - $ref: '#/components/schemas/MediaUrlResult'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - invalid_request
                - auth_error
                - rate_limit
                - insufficient_quota
                - content_policy
                - timeout
                - network_error
                - service_error
                - billable_error
                - unknown
            message:
              type: string
            param:
              type:
                - string
                - 'null'
            code:
              type:
                - string
                - 'null'
          required:
            - type
            - message
      required:
        - error
    ImageTaskResult:
      type: object
      description: 图片任务结果（OpenAI 图片格式），图片地址在 data[0].url。
      properties:
        created:
          type: integer
        data:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
                format: uri
              b64_json:
                type: string
              revised_prompt:
                type: string
      required:
        - data
    MediaUrlResult:
      type: object
      description: 视频或音频任务结果。主地址为 video_url 或 audio_url；全部产物同时列在 urls[]。
      properties:
        status:
          type: string
        video_url:
          type: string
          format: uri
        audio_url:
          type: string
          format: uri
        output_url:
          type: string
          format: uri
        urls:
          type: array
          items:
            type: string
            format: uri
  responses:
    BadRequest:
      description: 请求参数无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key

````