{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/animgen-com/json-schema/animgen-com-task-response-schema.json",
  "title": "TaskResponse",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/animgen-com-openapi.json#/components/schemas/TaskResponse",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id",
      "description": "Persist this task ID immediately after create; poll it instead of creating again.",
      "x-description-zh": "创建后立即保存任务 ID，通过它轮询，不要再次创建。"
    },
    "object": {
      "type": "string",
      "enum": [
        "video_generation",
        "animation_export",
        "animation"
      ],
      "title": "Object",
      "description": "Public task resource type.",
      "x-description-zh": "公共任务资源类型。"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "cancelling",
        "succeeded",
        "failed",
        "cancelled"
      ],
      "title": "Status",
      "description": "succeeded, failed, and cancelled are terminal; cancelling is not terminal.",
      "x-description-zh": "succeeded、failed、cancelled 为终态；cancelling 不是终态。"
    },
    "cancellation_allowed": {
      "type": "boolean",
      "title": "Cancellation Allowed",
      "description": "Whether a cancellation request can currently be accepted. Remote cancellation still needs confirmation.",
      "default": false,
      "x-description-zh": "当前是否允许受理取消请求；远端取消仍须确认。"
    },
    "cancellation_reason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Cancellation Reason",
      "description": "Stable reason when cancellation is unavailable: TASK_TERMINAL, CANCELLATION_PENDING, CANCELLATION_NOT_CONFIRMED, or GENERATION_ALREADY_SUBMITTED.",
      "x-description-zh": "不可取消的稳定原因：TASK_TERMINAL、CANCELLATION_PENDING、CANCELLATION_NOT_CONFIRMED 或 GENERATION_ALREADY_SUBMITTED。"
    },
    "stage": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "queued",
            "video_generation",
            "animation_export",
            "completed"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Stage",
      "description": "Current pipeline stage when available.",
      "x-description-zh": "可用时显示当前流水线阶段。"
    },
    "progress": {
      "type": "number",
      "maximum": 1.0,
      "minimum": 0.0,
      "title": "Progress",
      "description": "Fraction from 0 to 1, not a completion-time estimate.",
      "x-description-zh": "0 至 1 的进度值，不代表精确完成时间。"
    },
    "credits": {
      "$ref": "#/$defs/CreditUsage",
      "description": "Quoted, reserved, and charged credit states.",
      "x-description-zh": "报价、预占及已扣积分状态。"
    },
    "outputs": {
      "items": {
        "$ref": "#/$defs/AssetResponse"
      },
      "type": "array",
      "title": "Outputs",
      "description": "Available assets, including partial outputs on failed/cancelled tasks. Always inspect them at a terminal state.",
      "default": [],
      "x-description-zh": "可用资产，失败或取消也可能有部分产物；所有终态都应检查。"
    },
    "metadata": {
      "additionalProperties": true,
      "type": "object",
      "title": "Metadata",
      "description": "Caller-provided metadata.",
      "default": {},
      "x-description-zh": "调用方提供的元数据。"
    },
    "normalized_input": {
      "additionalProperties": true,
      "type": "object",
      "title": "Normalized Input",
      "description": "Normalized public input; may contain private prompts or image references. Do not log wholesale.",
      "default": {},
      "x-description-zh": "规范化公共输入，可能含私有提示词或图片引用，不要整体写入日志。"
    },
    "resolved_export": {
      "anyOf": [
        {
          "$ref": "#/$defs/ResolvedExport"
        },
        {
          "type": "null"
        }
      ],
      "description": "Persisted FPS sampling summary shared with the quote and manifest; null for legacy tasks.",
      "x-description-zh": "持久化的 FPS 采样摘要，与报价、Manifest 一致；历史任务为 null。"
    },
    "error": {
      "anyOf": [
        {
          "$ref": "#/$defs/TaskError"
        },
        {
          "type": "null"
        }
      ],
      "description": "Task failure details, independently of any usable outputs.",
      "x-description-zh": "任务失败信息，与是否存在可用产物分别判断。"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "UTC acceptance timestamp.",
      "x-description-zh": "任务被接受的 UTC 时间。"
    },
    "started_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Started At",
      "description": "UTC production start when known.",
      "x-description-zh": "已知时返回 UTC 生产开始时间。"
    },
    "finished_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Finished At",
      "description": "UTC terminal timestamp when known.",
      "x-description-zh": "已知时返回 UTC 终态时间。"
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "id",
    "object",
    "status",
    "progress",
    "credits",
    "created_at"
  ],
  "$defs": {
    "AssetResponse": {
      "properties": {
        "object": {
          "type": "string",
          "const": "asset",
          "title": "Object",
          "default": "asset"
        },
        "id": {
          "type": "string",
          "format": "uuid",
          "title": "Id",
          "description": "Stable public asset ID; use it to refresh download metadata.",
          "x-description-zh": "稳定公共资产 ID，用于刷新下载信息。"
        },
        "format": {
          "type": "string",
          "title": "Format",
          "description": "Artifact format; inspect actual outputs rather than assuming an array order.",
          "x-description-zh": "实际资产格式，不要依赖 outputs 固定顺序。"
        },
        "mime_type": {
          "type": "string",
          "title": "Mime Type",
          "description": "Asset media type.",
          "x-description-zh": "资产媒体类型。"
        },
        "byte_size": {
          "type": "integer",
          "title": "Byte Size",
          "description": "Expected file size in bytes.",
          "x-description-zh": "文件预期字节数。"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "title": "Created At",
          "description": "Creation timestamp in UTC.",
          "x-description-zh": "UTC 创建时间。"
        },
        "download_url": {
          "type": "string",
          "title": "Download Url",
          "description": "Sensitive short-lived signed URL. Download without a Bearer header, including after redirects; never log the URL.",
          "x-description-zh": "敏感短期签名 URL；下载及跳转时均不携带 Bearer 头，不记录此 URL。"
        },
        "download_expires_at": {
          "type": "string",
          "format": "date-time",
          "title": "Download Expires At",
          "description": "Signed URL expiry in UTC; refresh via asset lookup when expired.",
          "x-description-zh": "签名 URL 的 UTC 过期时间；过期后重新查询资产。"
        },
        "media": {
          "anyOf": [
            {
              "$ref": "#/$defs/MediaResponse"
            },
            {
              "type": "null"
            }
          ],
          "description": "Whitelisted measured video metadata. Unknown fields are null; non-video assets return null.",
          "x-description-zh": "白名单内的实测视频信息，未知字段为 null；非视频资产为 null。"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id",
        "format",
        "mime_type",
        "byte_size",
        "created_at",
        "download_url",
        "download_expires_at"
      ],
      "title": "AssetResponse"
    },
    "CreditUsage": {
      "properties": {
        "quoted": {
          "type": "integer",
          "title": "Quoted",
          "description": "Quoted total, not necessarily the final charge.",
          "x-description-zh": "报价总额，不一定等于最终扣费。"
        },
        "held": {
          "type": "integer",
          "title": "Held",
          "description": "Credits currently reserved, not an additional charge to sum with charged.",
          "x-description-zh": "当前预占积分，不应与 charged 相加当作扣费。"
        },
        "charged": {
          "type": "integer",
          "title": "Charged",
          "description": "Net charged credits. Confirmed provider moderation rejection is refunded; cancellation alone is not a refund.",
          "x-description-zh": "最终净扣费积分。供应商明确审核拒绝会退分，取消本身不代表退款。"
        },
        "refunded": {
          "type": "integer",
          "title": "Refunded",
          "description": "Credits returned after a charge; already excluded from charged. Not a cash refund.",
          "default": 0,
          "x-description-zh": "扣费后退回的积分，已从 charged 中扣除，不是现金退款。"
        },
        "released": {
          "type": "integer",
          "title": "Released",
          "description": "Credits returned from an uncommitted hold.",
          "default": 0,
          "x-description-zh": "尚未确认扣费即释放的积分。"
        },
        "status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Status",
          "description": "Billing state: held, charged, released, refunded, or managed for internal child tasks.",
          "x-description-zh": "积分状态：held、charged、released、refunded，内部子任务可为 managed。"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "quoted",
        "held",
        "charged"
      ],
      "title": "CreditUsage"
    },
    "ExportWarning": {
      "properties": {
        "code": {
          "type": "string",
          "title": "Code"
        },
        "message": {
          "type": "string",
          "title": "Message"
        },
        "details": {
          "additionalProperties": true,
          "type": "object",
          "title": "Details",
          "default": {}
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "title": "ExportWarning"
    },
    "MediaResponse": {
      "properties": {
        "duration_seconds": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Duration Seconds",
          "description": "Playable video duration measured from presentation timestamps; never provider-requested duration.",
          "x-description-zh": "根据呈现时间戳测得的可播放视频时长，不使用供应商请求时长。"
        },
        "fps": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Fps",
          "description": "Measured average source frame rate; use presentation timestamps for VFR selection.",
          "x-description-zh": "实测源平均帧率；可变帧率选帧仍依据呈现时间戳。"
        },
        "frame_count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Frame Count",
          "description": "Decoded source frame count, or null when unknown.",
          "x-description-zh": "解码源帧数，未知为 null。"
        },
        "width": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Width",
          "description": "Displayed video width in pixels, accounting for rotation.",
          "x-description-zh": "考虑旋转后的显示宽度，单位像素。"
        },
        "height": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Height",
          "description": "Displayed video height in pixels, accounting for rotation.",
          "x-description-zh": "考虑旋转后的显示高度，单位像素。"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "MediaResponse"
    },
    "ResolvedExport": {
      "properties": {
        "selection": {
          "$ref": "#/$defs/Selection",
          "description": "Resolved source interval; full uses measured playable duration.",
          "x-description-zh": "实际源区间，full 使用实测可播放时长。"
        },
        "fps": {
          "type": "number",
          "title": "Fps",
          "description": "Target sampling frequency; never recalculated as frame_count / duration.",
          "x-description-zh": "目标采样频率，不按帧数除以时长重新计算。"
        },
        "frame_count": {
          "type": "integer",
          "title": "Frame Count",
          "description": "Number of samples strictly before the selected end.",
          "x-description-zh": "严格位于选区终点前的采样帧数。"
        },
        "duration_ms": {
          "type": "integer",
          "title": "Duration Ms",
          "description": "Sum of manifest frame durations in milliseconds.",
          "x-description-zh": "Manifest 逐帧时长的毫秒总和。"
        },
        "warnings": {
          "items": {
            "$ref": "#/$defs/ExportWarning"
          },
          "type": "array",
          "title": "Warnings",
          "description": "Sampling warnings, including repeated source frames without interpolation.",
          "default": [],
          "x-description-zh": "采样警告，包含未补帧而重复采到源帧的情况。"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "selection",
        "fps",
        "frame_count",
        "duration_ms"
      ],
      "title": "ResolvedExport"
    },
    "Selection": {
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "full",
            "range"
          ],
          "title": "Mode",
          "description": "full uses the complete source; range requires duration_seconds.",
          "default": "full",
          "x-description-zh": "full 使用完整来源；range 必须提供 duration_seconds。"
        },
        "start_seconds": {
          "type": "number",
          "minimum": 0.0,
          "title": "Start Seconds",
          "description": "Range start in seconds from the source beginning.",
          "default": 0.0,
          "x-description-zh": "相对源视频起点的选段开始秒数。"
        },
        "duration_seconds": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Duration Seconds",
          "description": "Required when mode=range; positive interval length in seconds.",
          "x-description-zh": "mode=range 时必填，选段时长秒数必须为正。"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "Selection"
    },
    "TaskError": {
      "properties": {
        "code": {
          "type": "string",
          "title": "Code",
          "description": "Machine-readable task error code.",
          "x-description-zh": "供程序识别的任务错误码。"
        },
        "message": {
          "type": "string",
          "title": "Message",
          "description": "Human-readable summary, not a stable branching key.",
          "x-description-zh": "人类可读说明，不应作为稳定分支条件。"
        },
        "retryable": {
          "type": "boolean",
          "title": "Retryable",
          "description": "Whether retry may help; inspect partial outputs before creating a new paid task.",
          "default": false,
          "x-description-zh": "重试是否可能有帮助；新建付费任务前先检查部分产物。"
        },
        "param": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Param",
          "description": "Related public parameter when available.",
          "x-description-zh": "可用时提供相关公开参数。"
        },
        "details": {
          "additionalProperties": true,
          "type": "object",
          "title": "Details",
          "description": "Public error details, without private storage or provider values.",
          "default": {},
          "x-description-zh": "公开错误详情，不含私有存储或供应商值。"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "title": "TaskError"
    }
  }
}