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

# 创建视频

> 创建异步视频生成任务。每20秒轮询返回的`polling_url`，直到任务达到终态。

需要工作区的预览功能访问权限。有关设置、Webhook 和结果处理，请参阅[视频与批处理任务](../../guides/async-video-and-batch.mdx)。


## OpenAPI

````yaml zh-Hans/openapi/v1/openapi.localized.yaml POST /videos
openapi: 3.0.3
info:
  title: Phaseo Gateway API
  description: 通过兼容 OpenAI 的端点访问各种 AI 模型的网关 API。
  version: 1.0.0
  contact:
    name: Phaseo
    url: https://phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
    description: 全球路由
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core Phaseo Gateway operations.
paths:
  /videos:
    post:
      tags:
        - Gateway
      summary: 创建视频
      description: 创建异步视频生成任务。每20秒轮询返回的`polling_url`，直到任务达到终态。
      operationId: createVideo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoGenerationRequest'
      responses:
        '202':
          description: 视频响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoGenerationResponse'
components:
  schemas:
    VideoGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
        prompt:
          type: string
        duration:
          type: integer
          description: 所需时长（秒），取决于提供商／模型。
        input_video_duration:
          type: number
          format: double
          minimum: 0
          maximum: 3600
          exclusiveMinimum: true
          description: 源视频时长（秒）。提供商对源视频时长与生成输出分别计费时必填。
        input_audio_duration:
          type: number
          format: double
          minimum: 2
          maximum: 20
          description: 声明的源音频时长（秒），用于验证提供商允许的范围。不报告权威使用量的提供商可能按其支持的输入时长上限计费。
        size:
          type: string
          description: 明确尺寸（例如1280x720）。不能与resolution或aspect_ratio组合使用。
        resolution:
          type: string
          description: 480p、720p、1080p、1K、2K、4K。可与aspect_ratio组合使用。不能与size组合使用。
        aspect_ratio:
          type: string
          description: 宽高比，如16:9、9:16、1:1。可与resolution组合使用。不能与size组合使用。
        seed:
          type: integer
        sample_count:
          type: integer
          minimum: 1
          maximum: 4
        negative_prompt:
          type: string
        generate_audio:
          type: boolean
        enhance_prompt:
          type: boolean
        compression_quality:
          type: integer
        person_generation:
          type: string
        resize_mode:
          type: string
        input_references:
          type: array
          description: >-
            用于控制生成的HTTPS图像、音频或视频输入。支持的类型、角色、数量和组合取决于所选模型。提交任务前请检查GET
            /videos/models。此架构中省略的单数兼容别名input_reference接受multipart图像，或恰好包含file_id或image_url其中一个的对象。支持情况取决于提供商。
          items:
            $ref: '#/components/schemas/VideoInputReference'
        frame_images:
          type: array
          minItems: 1
          maxItems: 2
          description: >-
            首帧／尾帧的HTTPS图像。每个frame_type只能出现一次。不要同时提供input_reference或input_references中的帧角色。
          items:
            type: object
            additionalProperties: false
            required:
              - type
              - frame_type
              - image_url
            properties:
              type:
                type: string
                enum:
                  - image_url
              frame_type:
                type: string
                enum:
                  - first_frame
                  - last_frame
              image_url:
                type: object
                required:
                  - url
                properties:
                  url:
                    type: string
                    format: uri
        provider_params:
          type: object
          additionalProperties: true
          description: 仅限提供商特定扩展。完整请求透传以及重复的路由、提示词、回调或计费字段会被拒绝。
        provider_options:
          type: object
          additionalProperties:
            type: object
            additionalProperties: true
          description: >-
            以规范提供商ID（如atlascloud或byteplus）为键的扩展。仅转发所选提供商的选项。不能与provider_params组合使用。路由、提示词、回调、时长、分辨率和输出数量必须使用经过验证的顶层字段。
        output:
          $ref: '#/components/schemas/VideoOutputConfig'
        webhook:
          type: object
          required:
            - endpoint_id
          additionalProperties: false
          properties:
            endpoint_id:
              type: string
              description: 工作区管理的活动Webhook端点。其加密且可轮换的签名密钥绝不会存储在视频任务元数据中。
            events:
              type: array
              description: >-
                可选事件订阅。使用通用job.*事件或匹配的video.*事件，如video.status_changed、video.progress或video.completed。省略时使用job.status_changed和终态job.*事件。进度回调需显式包含job.progress或video.progress。提供时，至少一个事件必须适用于视频任务；仅含其他任务类型事件或格式错误的列表会被拒绝。
              items:
                type: string
        provider:
          $ref: '#/components/schemas/ProviderRoutingOptions'
    VideoGenerationResponse:
      type: object
      properties:
        id:
          type: string
        polling_url:
          type: string
        websocket_url:
          type: string
          format: uri
          description: 用于订阅标准化异步任务生命周期更新的WebSocket URL。
        model:
          type: string
        request_id:
          type: string
        session_id:
          type: string
        status:
          type: string
          enum:
            - queued
            - processing
            - completed
            - failed
            - cancelled
            - expired
        lifecycle_status:
          type: string
          enum:
            - pending
            - running
            - completed
            - failed
            - cancelled
            - expired
          description: 供轮询、WebSocket和Webhook使用方使用的标准化异步生命周期状态。
        cancel_url:
          type: string
          format: uri
          nullable: true
          description: 为兼容性保留；目前始终为null。
        output_access:
          type: string
          enum:
            - bytes
            - signed_url
            - both
        generation_id:
          type: string
          nullable: true
        native_video_id:
          type: string
          nullable: true
          description: 与网关自有ID不同时的提供商原生视频／任务ID。
        created_at:
          oneOf:
            - type: integer
            - type: string
        started_at:
          nullable: true
          oneOf:
            - type: integer
            - type: string
        completed_at:
          nullable: true
          oneOf:
            - type: integer
            - type: string
        object:
          type: string
          example: video
        poll_after_seconds:
          type: integer
          example: 20
        provider:
          type: string
        seconds:
          type: number
        size:
          type: string
        audio:
          type: boolean
        content_url:
          type: string
          description: 当output_access包含bytes时存在（需认证的端点）。
        download_url:
          type: string
          nullable: true
          description: 状态为completed时用于直接下载的第一方签名URL。
        expires_at:
          type: integer
          nullable: true
          description: 签名download_url过期的Unix时间戳（秒）。
        progress:
          type: integer
          nullable: true
        progress_source:
          type: string
        asset:
          type: object
          nullable: true
          properties:
            id:
              type: string
            mime_type:
              type: string
            bytes:
              type: integer
            sha256:
              type: string
            width:
              type: integer
            height:
              type: integer
            duration_seconds:
              type: number
        outputs:
          type: array
          items:
            $ref: '#/components/schemas/VideoOutput'
        billing:
          $ref: '#/components/schemas/VideoBillingSummary'
        webhook:
          $ref: '#/components/schemas/AsyncWebhookPublicState'
        next_webhook_retry_at:
          type: string
          nullable: true
          description: 下一次计划用户Webhook重试的ISO时间戳（如已排队）。
        last_webhook_progress:
          type: number
          nullable: true
          description: 最近向Webhook使用方发送的粗略进度区间。
        last_webhook_progress_at:
          type: string
          nullable: true
          description: 最近一次Webhook进度区间发送的ISO时间戳。
        last_webhook_dispatched_at:
          type: string
          nullable: true
          description: 最近一次Webhook发送尝试的ISO时间戳。
        usage:
          type: object
          properties:
            cost:
              type: number
            is_byok:
              type: boolean
          additionalProperties: true
        error:
          nullable: true
    VideoInputReference:
      description: >-
        带类型的HTTPS媒体输入。图像使用image_url，音频或视频使用media_url。角色描述模型应如何使用输入；支持情况因提供商和模型而异。
      oneOf:
        - type: object
          required:
            - type
            - image_url
          properties:
            type:
              type: string
              enum:
                - image_url
            role:
              type: string
              description: 所选模型对此图像的预期用途。
              enum:
                - first_frame
                - last_frame
                - reference
                - source
                - mask
            reference_type:
              type: string
            image_url:
              type: object
              required:
                - url
              properties:
                url:
                  type: string
                  format: uri
                  description: 可公开访问的HTTPS图像URL。
        - type: object
          required:
            - type
            - media_url
          properties:
            type:
              type: string
              enum:
                - video_url
                - audio_url
            role:
              type: string
              description: 所选模型对此音频或视频的预期用途。
              enum:
                - first_frame
                - last_frame
                - reference
                - source
                - mask
            reference_type:
              type: string
            media_url:
              type: object
              required:
                - url
              properties:
                url:
                  type: string
                  format: uri
                  description: 可公开访问的HTTPS音频或视频URL。
    VideoOutputConfig:
      type: object
      properties:
        access:
          type: string
          enum:
            - bytes
            - signed_url
            - both
          default: both
          description: bytes=仅认证content_url，signed_url=仅签名下载链接，both=包含两者。
    ProviderRoutingOptions:
      type: object
      description: 用于网关选择的提供商路由偏好设置。
      properties:
        order:
          type: array
          items:
            type: string
        only:
          type: array
          items:
            type: string
        ignore:
          type: array
          items:
            type: string
        include_alpha:
          type: boolean
          description: 在路由中包含 alpha 提供商（默认关闭）。
        allow_fallbacks:
          type: boolean
          nullable: true
          description: 失败后允许回退到其他符合条件的提供商。
        require_parameters:
          type: boolean
          nullable: true
          description: 路由前要求提供商支持所请求的参数。
        required_execution_region:
          type: string
          nullable: true
          description: 将路由限制为具有所需执行区域的提供商。
        required_data_region:
          type: string
          nullable: true
          description: 将路由限制为具有所需数据区域的提供商。
        require_zero_data_retention:
          type: boolean
          nullable: true
          description: 将路由限制为支持零数据保留的提供商。
        data_collection:
          type: string
          nullable: true
          enum:
            - allow
            - deny
        zdr:
          type: boolean
          nullable: true
        enforce_distillable_text:
          type: boolean
          nullable: true
        quantizations:
          type: array
          nullable: true
          items:
            type: string
        sort:
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
          description: 为此请求排列提供商，例如按价格、延迟或吞吐量排序。
        max_price:
          type: object
          properties:
            prompt:
              oneOf:
                - type: number
                - type: string
            completion:
              oneOf:
                - type: number
                - type: string
            image:
              oneOf:
                - type: number
                - type: string
            audio:
              oneOf:
                - type: number
                - type: string
            request:
              oneOf:
                - type: number
                - type: string
        preferred_min_throughput:
          oneOf:
            - type: number
            - type: object
              additionalProperties:
                type: number
        preferred_max_latency:
          oneOf:
            - type: number
            - type: object
              additionalProperties:
                type: number
    VideoOutput:
      type: object
      properties:
        index:
          type: integer
        mime_type:
          type: string
        bytes_available:
          type: boolean
        content_url:
          type: string
          description: 当output_access包含bytes时存在。
        download_url:
          type: string
          description: 此输出的第一方签名URL。
        expires_at:
          type: integer
          description: 此输出URL过期的Unix时间戳（秒）。
    VideoBillingSummary:
      type: object
      properties:
        currency:
          type: string
        estimated_provider_cost:
          type: string
          nullable: true
        estimated_user_cost:
          type: string
          nullable: true
        settled_provider_cost:
          type: string
          nullable: true
        settled_user_cost:
          type: string
          nullable: true
        state:
          type: string
          enum:
            - pending
            - estimated
            - settled
            - void
        billable:
          type: boolean
        total_nanos:
          type: integer
          nullable: true
        estimated_nanos:
          type: integer
          nullable: true
        reserved_nanos:
          type: integer
          nullable: true
        reservation_id:
          type: string
          nullable: true
        reservation_status:
          type: string
          nullable: true
        charge_reason:
          type: string
          nullable: true
        charged:
          type: boolean
          nullable: true
        billed_at:
          type: string
      additionalProperties: true
    AsyncWebhookPublicState:
      type: object
      description: >-
        已清理的异步Webhook配置及投递状态。绝不返回密钥；`has_secret`表示是否启用签名投递。签名投递包含x-phaseo-signature、x-phaseo-timestamp、x-phaseo-event-id、x-phaseo-event-type、x-phaseo-delivery-key、x-phaseo-attempt和x-phaseo-max-attempts请求头。
      properties:
        url:
          type: string
          format: uri
          nullable: true
        events:
          type: array
          items:
            type: string
        has_secret:
          type: boolean
        delivery:
          $ref: '#/components/schemas/AsyncWebhookDeliverySummary'
        attempts:
          type: array
          items:
            $ref: '#/components/schemas/AsyncWebhookDeliveryAttempt'
    AsyncWebhookDeliverySummary:
      type: object
      description: 网关管理的异步Webhook公开投递摘要。用于区分任务执行状态和Webhook投递健康状况。
      properties:
        total_attempts:
          type: integer
          description: 此任务记录的投递尝试总次数。
        delivered_events:
          type: integer
          description: 达到已投递状态的投递键数量。
        delivered_event_types:
          type: array
          description: 至少成功投递一次的投递键。
          items:
            type: string
          example:
            - video.completed
        pending_retries:
          type: integer
          description: 当前安排重试的投递键数量。
        next_retry_at:
          type: string
          nullable: true
          description: 下一次计划重试的ISO时间戳（如有）。
        last_attempt_at:
          type: string
          nullable: true
          description: 最近一次投递尝试的ISO时间戳。
        last_attempt_status:
          type: string
          nullable: true
          enum:
            - delivered
            - scheduled_retry
            - failed_permanently
          description: 最近一次投递尝试的结果。
        last_response_status:
          type: integer
          nullable: true
          description: Webhook目标返回的HTTP状态（如可用）。
        last_delivered_at:
          type: string
          nullable: true
          description: 最近一次成功投递的ISO时间戳。
        last_failure_at:
          type: string
          nullable: true
          description: 最近一次失败或正在重试的尝试的ISO时间戳。
        last_error_message:
          type: string
          nullable: true
          description: 最近一次投递错误消息（如可用）。
    AsyncWebhookDeliveryAttempt:
      type: object
      description: 最近一次网关管理的异步Webhook投递尝试。
      properties:
        id:
          type: string
          description: 用于审计和调试的稳定尝试标识符。
        delivery_key:
          type: string
          description: 此事件投递的幂等键。
          example: video.completed
        event_type:
          type: string
          description: 投递到Webhook目标的事件类型。
          example: video.completed
        status:
          type: string
          enum:
            - delivered
            - scheduled_retry
            - failed_permanently
        attempt_number:
          type: integer
          description: 此投递键从1开始的尝试编号。
        max_attempts:
          type: integer
          description: 将投递标记为永久失败之前的最大尝试次数。
        tried_at:
          type: string
          description: 进行此次尝试的ISO时间戳。
        delivered_at:
          type: string
          nullable: true
          description: 此次尝试成功投递的ISO时间戳。
        next_retry_at:
          type: string
          nullable: true
          description: 此次尝试后下一次重试的ISO时间戳（如已安排）。
        response_status:
          type: integer
          nullable: true
          description: Webhook目标返回的HTTP状态（如可用）。
        error_message:
          type: string
          nullable: true
          description: 投递错误消息（如可用）。
        response_body_preview:
          type: string
          nullable: true
          description: Webhook目标响应正文的已脱敏预览。
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer 令牌身份验证

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.