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

# 创建渲染任务

> 请求体有两种形式，由 `Content-Type` 决定使用哪种。

`multipart/form-data` 直接根据角色和动作输入创建渲染任务，每项输入可以是上传文件、URL 或已保存资产的 ID。这种形式返回 `200`；`Idempotency-Key` 可选，传了也会生效。

`application/json` 根据 `POST /v1/renders/prepare` 准备好的草稿创建渲染任务。这种形式返回 `202`，必须传 `Idempotency-Key`。

幂等键的作用域为 API 密钥，保留 24 小时：以相同输入复用某个键会返回原来的渲染任务，以不同输入复用则返回 `409 IDEMPOTENCY_KEY_REUSED`。

按成片时长计费，每个角色每秒 1 积分（$0.01），每个渲染任务最低 0.5 积分（$0.005）。单角色渲染为 $0.01/秒；多人渲染按 `character_mapping` 中的每个条目计为一个角色。创建时根据测得的动作时长（未知时按 10 秒）预扣一笔估算费用；渲染完成后按实际时长结算。积分不足返回 `402`。已取消或失败的渲染任务全额退款。

渲染任务仅对创建它的 API 密钥可见。结果 `video_url` 是 CDN URL；结果文件在渲染完成 24 小时后删除。




## OpenAPI

````yaml zh/openapi.yaml POST /v1/renders
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:
    post:
      tags:
        - Renders
      summary: 创建渲染任务
      description: >
        请求体有两种形式，由 `Content-Type` 决定使用哪种。


        `multipart/form-data` 直接根据角色和动作输入创建渲染任务，每项输入可以是上传文件、URL 或已保存资产的
        ID。这种形式返回 `200`；`Idempotency-Key` 可选，传了也会生效。


        `application/json` 根据 `POST /v1/renders/prepare` 准备好的草稿创建渲染任务。这种形式返回
        `202`，必须传 `Idempotency-Key`。


        幂等键的作用域为 API 密钥，保留 24 小时：以相同输入复用某个键会返回原来的渲染任务，以不同输入复用则返回 `409
        IDEMPOTENCY_KEY_REUSED`。


        按成片时长计费，每个角色每秒 1 积分（$0.01），每个渲染任务最低 0.5 积分（$0.005）。单角色渲染为 $0.01/秒；多人渲染按
        `character_mapping` 中的每个条目计为一个角色。创建时根据测得的动作时长（未知时按 10
        秒）预扣一笔估算费用；渲染完成后按实际时长结算。积分不足返回 `402`。已取消或失败的渲染任务全额退款。


        渲染任务仅对创建它的 API 密钥可见。结果 `video_url` 是 CDN URL；结果文件在渲染完成 24 小时后删除。
      operationId: createRender
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
        - $ref: '#/components/parameters/RequestId'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateRenderForm'
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRenderRequest'
      responses:
        '200':
          description: |
            通过直接的 `multipart/form-data` 请求受理的渲染任务。
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Render'
        '202':
          description: 根据已准备的草稿受理的渲染任务。
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Render'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/V1Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '404':
          description: >
            已保存的角色或动作（`character_id`、`motion_id`，或草稿中指定的）不存在、已删除，或该账户无法使用：错误码
            `CHARACTER_NOT_FOUND` 或 `MOTION_NOT_FOUND`。未知或已过期的 `draft_id` 返回
            `DRAFT_NOT_FOUND`。
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '408':
          $ref: '#/components/responses/UploadTimeout'
        '409':
          $ref: '#/components/responses/Conflict'
        '500':
          $ref: '#/components/responses/InternalServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >
        调用方生成的稳定键，最长 255 个字符，作用域为 API 密钥，保留 24 小时。`POST /v1/renders` 的
        `application/json` 草稿形式必须传；`multipart/form-data` 形式可选，传了也会生效。
      schema:
        type: string
        minLength: 1
        maxLength: 255
    RequestId:
      name: X-Request-Id
      in: header
      required: false
      description: 可选，调用方提供的关联 ID，会原样回显在响应头中。不传则由服务生成。用于链路追踪和技术支持。
      schema:
        type: string
        minLength: 1
  schemas:
    CreateRenderForm:
      description: >
        角色通过 `image`、`image_url`（或其别名 `ref_url`/`ref_image_url`）或 `character_id`
        之一提供，动作通过 `motion_video`、`motion_video_url`（或其别名
        `video_url`/`driving_video_url`）或 `motion_id`/`scene_id`
        之一提供。如果两组都完全未提供，服务器会改用其预配置的默认 `character_id`/`motion_id`
        进行渲染，而不是拒绝请求——只提供部分（例如有角色来源但没有动作来源）仍会报错。
      type: object
      properties:
        image:
          type: string
          format: binary
          description: 直接上传的角色图。`image`、`image_url` 和 `character_id` 中只能使用一个角色来源。
        image_url:
          type: string
          format: uri
          description: 服务可拉取的角色图公网 URL。用于替代 `image` 或 `character_id`。
        ref_url:
          type: string
          format: uri
          deprecated: true
          description: '`image_url` 的向后兼容别名。不要混用多个角色 URL 别名。'
        ref_image_url:
          type: string
          format: uri
          deprecated: true
          description: '`image_url` 的向后兼容别名。不要混用多个角色 URL 别名。'
        character_id:
          type: string
          description: 调用方拥有的已就绪可复用角色的 ID。用于替代上传或链接新图片。
          minLength: 1
        motion_video:
          type: string
          format: binary
          description: >-
            直接上传的驱动视频。`motion_video`、`motion_video_url` 和 `motion_id`
            中只能使用一个动作来源。
        motion_video_url:
          type: string
          format: uri
          description: 服务可拉取的驱动视频公网 URL。用于替代 `motion_video` 或 `motion_id`。
        video_url:
          type: string
          format: uri
          deprecated: true
          description: '`motion_video_url` 的向后兼容别名。不要混用多个动作 URL 别名。'
        driving_video_url:
          type: string
          format: uri
          deprecated: true
          description: '`motion_video_url` 的向后兼容别名。不要混用多个动作 URL 别名。'
        motion_id:
          type: string
          description: 调用方拥有的已就绪可复用动作的 ID。用于替代上传或链接新的驱动视频。
          minLength: 1
        scene_id:
          type: string
          deprecated: true
          description: '`motion_id`（可复用动作的内部名称）的向后兼容别名。不要同时发送两个字段。'
          minLength: 1
        mode:
          type: string
          enum:
            - full_pipeline
            - preprocessed
            - character_only
            - scene_preprocess
          description: 高级流水线模式。省略时，若提供了 Motion ID 则推断为 `preprocessed`，否则为 `full_pipeline`。
        background_mode:
          description: >
            `inpaint` 可被接受，并按 `original` 处理。该取值集合与
            `RenderOutputOptions.background_mode` 无关，后者属于基于草稿的流程。
          type: string
          enum:
            - original
            - solid
            - transparent
            - inpaint
          default: original
        bg_color:
          description: >
            纯色背景颜色，由三个十进制分量组成，格式为 `"R,G,B"`，例如 `"0,177,64"`。仅在
            `background_mode=solid` 时有效。
          type: string
          example: 0,177,64
        background_url:
          type: string
          format: uri
          description: 转发给渲染流水线的可选自定义背景图 URL。除非所选流水线模式支持，否则通常省略。
        model:
          type: string
          enum:
            - V3
            - v3
            - V3_Preview
            - V4
            - v4
            - V4_Preview
            - V4_BaseSG
          description: 可选的渲染模型。省略时由服务根据已保存的资产推断模型，或使用其配置的默认值。
        character_mapping:
          type: string
          description: >
            多人渲染。一个以字符串形式发送的 JSON 对象，将多人动作中的每个人（track ID）映射到调用方拥有的一个 `ready`
            角色；Character ID 可以使用公开的 `char_` 前缀。对于从模板导入的动作，track ID 是该模板中各个人物的
            UUID。不属于该动作 track 的键会返回
            400，消息中会列出有效的键。未包含在映射中的人物使用主角色来源（`character_id`、`image` 或
            `image_url`）渲染，主角色来源仍为必填。计费时每个映射条目计为一个角色。
    CreateRenderRequest:
      type: object
      additionalProperties: false
      required:
        - draft_id
      properties:
        draft_id:
          type: string
          description: >-
            `POST /v1/renders/prepare` 返回的草稿标识符。草稿有效期 1 小时；每次使用新的
            `Idempotency-Key` 提交都会创建一个新的渲染任务。
          minLength: 1
        upload_completions:
          type: array
          description: >-
            可选。服务会自行校验每个计划上传（是否存在、大小，以及声明了 `sha256` 时的摘要）；缺少上传时返回 `400
            INVALID_REQUEST`。
          items:
            $ref: '#/components/schemas/UploadCompletion'
    Render:
      description: |
        对于不带此类信息的渲染任务，`stage`、`progress` 和 `created_at` 为 null。读取时请将它们视为可选字段。

        该资源响应提供结果 URL，但不提供媒体尺寸、时长、缩略图 URL 或 URL 过期时间等元数据。客户端不得根据本契约推断这些字段。
      type: object
      additionalProperties: false
      required:
        - id
        - status
        - stage
        - progress
        - video_url
        - alpha_url
        - created_at
        - completed_at
        - error
      properties:
        id:
          type: string
          description: 公开的 Render ID，通常以 `render_` 开头；用于获取、事件和下载操作。
          minLength: 1
        status:
          description: 渲染任务的整体生命周期。`ready`、`failed` 和 `cancelled` 为终态。
          allOf:
            - $ref: '#/components/schemas/RenderStatus'
        stage:
          type: string
          description: 可映射到公开词汇时的粗粒度流水线阶段；不可用或未知时为 null。
          nullable: true
          allOf:
            - $ref: '#/components/schemas/RenderStage'
        progress:
          type: integer
          description: 尽力估算的完成百分比，范围 0 到 100；流水线上报进度前为 `0`。
          minimum: 0
          maximum: 100
        video_url:
          type: string
          description: 渲染完成视频的 CDN URL；渲染任务就绪前或未产生输出时为 null。结果文件在渲染任务结束 24 小时后删除。
          nullable: true
          format: uri
        alpha_url:
          type: string
          description: 透明背景输出的 alpha/遮罩视频 CDN URL；非透明渲染任务或尚未就绪时为 null。
          nullable: true
          format: uri
        created_at:
          type: string
          description: 渲染任务的创建时间（ISO 8601）；后端流水线未提供时为 null。
          nullable: true
          format: date-time
        completed_at:
          type: string
          description: 渲染任务进入终态的时间（ISO 8601）；仍在进行中时为 null。
          nullable: true
          format: date-time
        error:
          type: object
          description: '`status` 为 `failed` 时的结构化失败详情；否则为 null。'
          nullable: true
          allOf:
            - $ref: '#/components/schemas/RenderFailure'
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - error
      properties:
        error:
          description: 错误负载，包含稳定的错误代码、消息、重试建议、关联 ID 以及特定于该错误的详情。
          allOf:
            - $ref: '#/components/schemas/ErrorBody'
    UploadCompletion:
      type: object
      additionalProperties: false
      required:
        - upload_handle
      properties:
        upload_handle:
          type: string
          description: 来自对应 `UploadPlan` 的不透明句柄，用于告知服务是哪个计划输入已完成上传。
          minLength: 1
        etag:
          type: string
          description: 对象存储上传响应返回的可选 ETag；如果存储服务返回的值带引号，需保留引号。
          minLength: 1
    RenderStatus:
      type: string
      enum:
        - queued
        - processing
        - ready
        - failed
        - cancelled
    RenderStage:
      description: |
        粗粒度的进度提示，仅在渲染任务处于 `processing` 时设置。遇到无法识别的值时，应视为“进行中”而不是报错。
      type: string
      enum:
        - analyzing
        - rendering
        - finishing
    RenderFailure:
      type: object
      additionalProperties: false
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 稳定的机器可读失败代码。请据此进行程序化处理，而不要解析消息文本。
        message:
          type: string
          description: 人类可读的渲染失败原因说明。
        details:
          type: object
          description: 由失败服务提供的附加结构化上下文；键因错误代码而异。
          additionalProperties: true
        request_id:
          type: string
          description: 提供给技术支持的请求或 worker 关联标识符；失败未关联任何标识符时为 null。
          nullable: true
        retryable:
          type: boolean
          description: 再次提交相同的渲染任务是否可能成功。
        remediation:
          description: 建议的恢复操作及可选的重试延迟。
          allOf:
            - $ref: '#/components/schemas/ErrorRemediation'
    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'
    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
    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
  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'
    PaymentRequired:
      description: 积分不足。
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UploadTimeout:
      description: >-
        multipart 上传未能在 10 分钟的读取截止时间内传完。错误码 `UPLOAD_TIMEOUT`，可重试：直接重试，或改传 URL
        代替文件。
      headers:
        X-Request-Id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Conflict:
      description: 状态冲突或幂等冲突。
      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.