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

# 准备渲染任务



## OpenAPI

````yaml zh/openapi.yaml POST /v1/renders/prepare
openapi: 3.0.3
info:
  title: Viggle API
  description: >
    Viggle API 可生成 AI 视频（Viggle H3、Viggle Remake、Video Remix）、图片（Viggle Image）、2
    倍视频超分（FlashVSR），以及 JST-2 3D 角色、动作和场景。所有任务都是异步的：先创建，再轮询（渲染任务也可监听进度），直到任务进入终态。


    基础 URL：`https://apis.viggle.ai`。每个请求都需通过 `Authorization: Bearer <API key>`
    认证。用量按积分计费（1 积分 = $0.01）。指南与价格：https://docs.viggle.ai/zh/v1/introduction
  version: 2.0.0
  contact:
    name: Viggle Support
    url: https://viggle.ai
servers:
  - url: https://apis.viggle.ai
    description: 生产环境服务器
security:
  - bearerAuth: []
tags:
  - name: Renders
    description: >-
      Video Remix（JST-1）。准备输入、创建渲染任务、监听进度、取消以及下载结果。渲染任务的状态通过 `GET
      /v1/videos/{video_id}` 读取。
  - name: Credits
    description: 读取调用方 API 密钥可用的积分余额。
  - name: Characters
    description: |
      创建、列出、查看和删除可复用的角色资产。`type` 决定创建时是否同时提取 3D vsplat；就绪后需单独导出其下载链接。
  - name: Motions
    description: |
      创建、列出、查看和删除可复用的动作资产，也可从官方动作模板导入。`type` 决定创建时是否同时提取或生成 3D 动画；就绪后需单独导出其下载链接。
  - name: Videos
    description: >
      从文本、帧或参考素材生成 Viggle H3 视频（`vid_` 前缀），或从驱动视频和角色图生成 Viggle Remake 视频（`anim_`
      前缀）；用 FlashVSR 将视频超分 2 倍（`vsr_` 前缀）；并以统一视图读取调用方 API 密钥创建的所有视频——H3
      生成、Remake 生成以及 Video Remix 渲染任务（`render_` 前缀）——合并为同一种资源。
  - name: Images
    description: |
      Viggle Image——根据文本提示词生成 1–6 张 PNG 图片，可选用最多 8 张参考图引导（`img_` 前缀），并可按 ID 获取。
  - name: Scenes
    description: >
      场景模型——从文本提示词或 360° 全景图构建 3D
      高斯泼溅场景（`.spz`），生成新的指定位姿视角，并基于这些视角重建场景。每个操作都是一个异步任务（`scn_` 前缀），按 ID
      读取结果。每次运行按每个视角 1 积分计费，一张全景图计为 6 个视角。除非任务以 `ready` 结束，否则积分全额退款。
paths:
  /v1/renders/prepare:
    post:
      tags:
        - Renders
      summary: 准备渲染任务
      operationId: prepareRender
      parameters:
        - $ref: '#/components/parameters/RequestId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PrepareRenderRequest'
      responses:
        '200':
          description: 草稿，以及创建渲染任务前需要完成的上传（如有）。
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrepareRenderResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/V1Unauthorized'
        '404':
          description: >-
            草稿中指定的已保存角色或动作不存在、已删除，或该账户无法使用。错误码 `CHARACTER_NOT_FOUND` 或
            `MOTION_NOT_FOUND`。
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  parameters:
    RequestId:
      name: X-Request-Id
      in: header
      required: false
      description: 可选，调用方提供的关联 ID，会原样回显在响应头中。不传则由服务生成。用于链路追踪和技术支持。
      schema:
        type: string
        minLength: 1
  schemas:
    PrepareRenderRequest:
      type: object
      additionalProperties: false
      required:
        - character
        - motion
      properties:
        character:
          description: 渲染任务的角色输入。三种来源形式必须且只能选择一种：直传元数据、公网 HTTPS URL 或可复用资产 ID。
          allOf:
            - $ref: '#/components/schemas/CharacterSource'
        motion:
          description: >-
            渲染任务的动作输入。可选择直传、公网 HTTPS URL 或可复用的 Motion ID。如需使用 Viggle 动作模板，请先通过
            `POST /v1/motions/import` 导入，再传入得到的 Motion ID。
          allOf:
            - $ref: '#/components/schemas/MotionSource'
        output:
          description: 可选的输出设置。省略的字段使用 `RenderOutputOptions` 中所述的服务默认值。
          allOf:
            - $ref: '#/components/schemas/RenderOutputOptions'
    PrepareRenderResponse:
      type: object
      additionalProperties: false
      required:
        - draft_id
        - state
        - uploads
      properties:
        draft_id:
          type: string
          description: 不透明的渲染草稿标识符。完成所有必需的上传后，将其原样传给 `POST /v1/renders`。
          minLength: 1
        state:
          type: string
          description: 创建前是否需要先完成媒体上传。`ready_to_create` 表示草稿可立即提交。
          enum:
            - awaiting_uploads
            - ready_to_create
        uploads:
          type: array
          description: '以 `kind: upload` 声明的输入对应的直传计划；当所有来源都已可供服务使用时为空。'
          items:
            $ref: '#/components/schemas/UploadPlan'
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - error
      properties:
        error:
          description: 错误负载，包含稳定的错误代码、消息、重试建议、关联 ID 以及特定于该错误的详情。
          allOf:
            - $ref: '#/components/schemas/ErrorBody'
    CharacterSource:
      oneOf:
        - $ref: '#/components/schemas/UploadSource'
        - $ref: '#/components/schemas/UrlSource'
        - $ref: '#/components/schemas/AssetSource'
    MotionSource:
      oneOf:
        - $ref: '#/components/schemas/UploadSource'
        - $ref: '#/components/schemas/UrlSource'
        - $ref: '#/components/schemas/AssetSource'
    RenderOutputOptions:
      type: object
      additionalProperties: false
      properties:
        background_mode:
          description: >
            控制背景的生成方式。`original` 保留或重建源视频背景；`green` 和 `white`
            会转换为流水线的纯色模式并使用对应颜色；`transparent` 额外输出一路 alpha/遮罩视频，用于合成。
          type: string
          enum:
            - original
            - green
            - white
            - transparent
        aspect_ratio:
          description: |
            目前仅支持 `source`。渲染流水线暂不支持重新构图，因此其他值会被直接拒绝，而不是被静默忽略。
          type: string
          enum:
            - source
            - '16:9'
            - '9:16'
            - '1:1'
    UploadPlan:
      type: object
      additionalProperties: false
      required:
        - slot
        - upload_handle
        - method
        - url
        - required_headers
        - expires_at
      properties:
        slot:
          type: string
          description: 此次上传对应的输入槽位。将对应的角色图或动作视频上传到所给 URL。
          enum:
            - character
            - motion
        upload_handle:
          type: string
          description: 本次计划上传的不透明标识符。
          minLength: 1
        method:
          type: string
          description: 直传所需的 HTTP 方法；目前始终为 `PUT`。
          enum:
            - PUT
        url:
          type: string
          format: uri
          description: 预签名 URL，有效期 1 小时，媒体字节需直接上传到该地址。
        required_headers:
          type: object
          description: 直传时必须原样携带的 HTTP 请求头，通常包括声明的内容类型。
          additionalProperties:
            type: string
        expires_at:
          type: string
          format: date-time
          description: 预签名上传 URL 的过期时间（ISO 8601）。如果无法在此之前完成上传，请重新准备一个草稿。
    ErrorBody:
      type: object
      additionalProperties: false
      required:
        - code
        - message
        - retryable
        - request_id
        - details
        - remediation
      properties:
        code:
          description: 稳定的机器可读错误代码。请据此进行程序化处理，而不要解析 `message`。
          allOf:
            - $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: 人类可读的说明，适合写入日志或展示给开发者。
        retryable:
          type: boolean
          description: 不修改输入直接重试该操作是否可能成功。HTTP 408、429 和 5xx 响应为 true。
        request_id:
          type: string
          description: 用于追踪和技术支持的关联标识符。报告失败时请附上。
        details:
          type: object
          description: 特定于该错误的结构化上下文；可用的键取决于 `code`。
          additionalProperties: true
        remediation:
          description: 建议的恢复操作及可选的重试延迟。
          allOf:
            - $ref: '#/components/schemas/ErrorRemediation'
    UploadSource:
      type: object
      additionalProperties: false
      required:
        - kind
        - filename
        - content_type
        - bytes
      properties:
        kind:
          type: string
          description: 来源类型标识。媒体将通过返回的直传计划上传时，设为 `upload`。
          enum:
            - upload
        filename:
          type: string
          description: 原始文件名（含扩展名），用于识别和校验上传的媒体。
          minLength: 1
        content_type:
          type: string
          description: 待上传文件的 MIME 类型，例如 `image/png` 或 `video/mp4`；必须与上传请求的请求头一致。
          minLength: 1
        bytes:
          type: integer
          format: int64
          description: 精确的文件大小（字节）。上传对象的大小会与该声明值核对。
          minimum: 1
        sha256:
          type: string
          description: 可选，上传字节内容的 SHA-256 摘要，编码为 64 个小写十六进制字符。提供后，服务会在创建渲染任务前进行校验。
          pattern: ^[0-9a-f]{64}$
    UrlSource:
      type: object
      additionalProperties: false
      required:
        - kind
        - url
      properties:
        kind:
          type: string
          description: 来源类型标识。需要 Viggle 从远程 HTTPS 地址拉取媒体时，设为 `url`。
          enum:
            - url
        url:
          type: string
          format: uri
          description: 源媒体的公网可访问 HTTPS URL。在渲染任务准备期间，该 URL 必须保持可访问。
          pattern: ^https://
    AssetSource:
      type: object
      additionalProperties: false
      required:
        - kind
        - asset_id
      properties:
        kind:
          type: string
          description: 来源类型标识。复用调用方账户中已存储的角色或动作时，设为 `asset`。
          enum:
            - asset
        asset_id:
          type: string
          description: 已就绪的可复用资产 ID。角色槽位填 Character ID，动作槽位填 Motion ID。
          minLength: 1
    ErrorCode:
      description: >
        API 返回的错误代码，出现在同步错误信封以及失败任务的 `error` 对象中。客户端应能容忍此处未列出的代码。没有公开映射的异步失败会以
        `PROCESSING_FAILED` 呈现。
      type: string
      enum:
        - INVALID_REQUEST
        - UNAUTHENTICATED
        - INVALID_CREDENTIAL
        - INSUFFICIENT_CREDITS
        - RENDER_NOT_FOUND
        - CHARACTER_NOT_FOUND
        - MOTION_NOT_FOUND
        - DRAFT_NOT_FOUND
        - NOT_FOUND
        - RESULT_EXPIRED
        - IDEMPOTENCY_KEY_REUSED
        - ID_ALREADY_EXISTS
        - UPLOAD_TIMEOUT
        - CONTENT_POLICY_VIOLATION
        - RATE_LIMITED
        - SERVICE_BUSY
        - INTERNAL_ERROR
        - IMAGE_REQUIRED
        - MOTION_VIDEO_REQUIRED
        - UNSUPPORTED_MEDIA
        - VIDEO_TOO_LONG
        - VIDEO_TOO_LARGE
        - VIDEO_RESOLUTION_TOO_HIGH
        - VIDEO_UNREADABLE
        - VIDEO_DIMENSIONS_MUST_BE_EVEN
        - VIDEO_INACCESSIBLE
        - NO_HUMANS_DETECTED
        - MOTION_NOT_READY
        - MOTION_MODEL_MISMATCH
        - INVALID_BACKGROUND_MODE
        - ALL_WORKERS_BUSY
        - WORKER_STOPPED
        - TASK_FAILED
        - PROCESSING_FAILED
    ErrorRemediation:
      type: object
      additionalProperties: false
      required:
        - action
        - retry_after_ms
      properties:
        action:
          type: string
          enum:
            - none
            - retry
          description: 建议的下一步操作。同步错误始终为 `none`；失败任务的 `error` 在失败可重试时为 `retry`。
        retry_after_ms:
          type: integer
          description: 重试前建议等待的毫秒数；不建议定时重试时为 null。
          nullable: true
          format: int64
          minimum: 0
  headers:
    RequestId:
      description: 用于技术支持和链路追踪的稳定请求标识。
      schema:
        type: string
  responses:
    BadRequest:
      description: 请求无效。
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    V1Unauthorized:
      description: 缺少 API 密钥或 API 密钥无效。错误码 `UNAUTHENTICATED`。
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: 服务器意外错误。
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServiceUnavailable:
      description: 服务暂时不可用。
      headers:
        Retry-After:
          schema:
            type: integer
            minimum: 0
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: >
        以 `Authorization: Bearer <API key>` 的形式发送 API 密钥。密钥以 `sk-`
        开头。缺少密钥或密钥无效时返回 `401 UNAUTHENTICATED`。切勿在浏览器代码中暴露 API 密钥。

````

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