{
  "openapi": "3.0.3",
  "info": {
    "title": "Atelier 151A 视频节点",
    "version": "1.3.0"
  },
  "servers": [
    {
      "url": "https://43.155.26.44/hk-api"
    }
  ],
  "security": [
    {
      "canvas": []
    }
  ],
  "components": {
    "schemas": {
      "Draft": {"type":"object","required":["prompt","aspect","seconds","operation"],"properties":{
        "prompt":{"type":"string","maxLength":6999},
        "operation":{"type":"string","enum":["generate","continue"]},
        "aspect":{"$ref":"#/paths/~1orders/post/requestBody/content/application~1json/schema/properties/aspect"},
        "seconds":{"$ref":"#/paths/~1orders/post/requestBody/content/application~1json/schema/properties/seconds"},
        "references":{"$ref":"#/paths/~1orders/post/requestBody/content/application~1json/schema/properties/references"},
        "reference_roles":{"type":"object","additionalProperties":{"type":"string"}},
        "parent_id":{"type":"string","pattern":"^[0-9a-f]{32}$"},
        "sound_mode":{"type":"string","enum":["有台词","无台词"]},
        "video_skip":{"type":"integer","minimum":0},"video_frames":{"type":"integer","minimum":0},
        "confirmed_settings":{"type":"boolean"},"confirm_node_template":{"type":"boolean"}
      }}
    },
    "securitySchemes": {
      "canvas": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "paths": {
    "/account": {
      "get": {
        "operationId": "getAccount",
        "summary": "查看当前账号、接单权限和临时空间提示",
        "responses": {
          "200": {
            "description": "空间正常时 storage_notice 为空。空间不足时已接订单仍可在原期限内取片。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "member_id": {"type": "string"},
                    "generation": {"type": "boolean"},
                    "prompt_policy":{"type":"object","properties":{"smart_enabled":{"type":"boolean"},"smart_writer_included":{"type":"boolean","description":"已核价的智能分段费用计入生成整单报价。须用 smart 主动选用。"},"draft_points":{"type":"integer","nullable":true}}},
                    "storage_notice": {
                      "type": "object", "nullable": true,
                      "properties": {
                        "state": {"type": "string", "enum": ["warning", "limited"]},
                        "message": {"type": "string", "description": "显示给当前用户的提示"}
                      },
                      "required": ["state", "message"]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/prompt-quote": {
      "post":{"operationId":"quoteDraft","summary":"免费核对素材并获取整理报价",
        "requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Draft"}}}},
        "responses":{"200":{"description":"quote_id 标识报价内容；request_id 标识本次整理。若有 retry_of，上一回已明确释放，须得到同意才能用新编号再试。另含整数 points、enabled、issues、warnings 与 reasons。此步不调用写作服务。"}}}
    },
    "/prompt-organize": {
      "post":{"operationId":"organizeDraft","summary":"按已接受的点数报价整理草稿；不会创建视频订单",
        "requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Draft"},
          {"type":"object","required":["request_id","max_points"],"properties":{"request_id":{"type":"string","pattern":"^[0-9a-f]{32}$"},
          "retry_of":{"type":"string","pattern":"^[0-9a-f]{32}$","description":"确认重新尝试后使用报价中提供的上次未交付编号"},"max_points":{"type":"integer","minimum":0,"description":"以当前报价为准，0 表示已包含、不另扣创作点数。"}}}]}}}},
        "responses":{"200":{"description":"已交付的草稿、已扣点数和整理编号。相同编号和正文重试会返回同一份草稿。"},
          "402":{"description":"创作点数不足"},"409":{"description":"报价已变化、正在整理或编号已使用"},"422":{"description":"请检查指定的素材、正文或用途"}}}
    },
    "/prompt-organize/{request_id}": {
      "get":{"operationId":"getDraft","summary":"查询本账号的一次整理",
        "parameters":[{"name":"request_id","in":"path","required":true,"schema":{"type":"string","pattern":"^[0-9a-f]{32}$"}}],
        "responses":{"200":{"description":"正在整理、已释放或原草稿"},"404":{"description":"找不到本账号的该次整理"}}}
    },
    "/orders": {
      "post": {
        "operationId": "submitVideo",
        "summary": "提交镜头（同一请求重试复用 nonce）",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nonce": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{32}$"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "generate",
                      "continue",
                      "upscale"
                    ]
                  },
                  "parent_id": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{32}$"
                  },
                  "title": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "prompt_mode":{"type":"string","enum":["original","smart"],"description":"省略将沿用原稿。智能检查根据账号的 prompt_policy 开放。仅在 smart_writer_included 时，已明确标注的外部格式可能交由写作服务分段，包含在视频报价中。"},
                  "confirm_node_template":{"type":"boolean","description":"仅在调用方确认匹配的末尾模板由节点追加时设为 true。"},
                  "preparation_id":{"type":"string","pattern":"^[0-9a-f]{32}$","description":"关联本账号同原文和同素材的已交付整理稿；不会再收整理费。"},
                  "seconds": {
                    "type": "number",
                    "minimum": 5,
                    "maximum": 15
                  },
                  "tier": {
                    "type": "string",
                    "enum": [
                      "480P",
                      "720P",
                      "1080P"
                    ]
                  },
                  "aspect": {
                    "type": "string",
                    "enum": [
                      "16:9",
                      "9:16",
                      "1:1",
                      "3:4",
                      "4:3",
                      "21:9",
                      "4:5"
                    ]
                  },
                  "sound_mode": {
                    "type": "string",
                    "enum": [
                      "有台词",
                      "无台词"
                    ]
                  },
                  "seed": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "references": {
                    "type": "object",
                    "properties": {
                      "images": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^[0-9a-f]{32}$"
                        },
                        "maxItems": 6
                      },
                      "audio": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^[0-9a-f]{32}$"
                        },
                        "maxItems": 3
                      },
                      "video": {
                        "type": "string",
                        "pattern": "^[0-9a-f]{32}$"
                      },
                      "use_video_audio": {
                        "type": "boolean"
                      }
                    }
                  }
                },
                "required": [
                  "nonce"
                ]
              }
            }
          }
        },
        "responses": {
          "503": {"description": "storage_limited 表示临时空间不足。保留原请求编号，恢复接单后再试。"},
          "200": {
            "description": "原单",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{32}$"
                    },
                    "status": {
                      "type": "string"
                    },
                    "requested_seconds": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "status"
                  ]
                }
              }
            }
          },
          "202": {
            "description": "已受理",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{32}$"
                    },
                    "status": {
                      "type": "string"
                    },
                    "requested_seconds": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "id",
                    "status"
                  ]
                }
              }
            }
          },
          "402": {
            "description": "可用创作点数为 0 或负数。正余额允许受理一单并冻结至负数，批量逐单检查。"
          },
          "409": {
            "description": "原单参数冲突或父片不可用"
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "operationId": "getVideoStatus",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "订单状态",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{32}$"
                    },
                    "status": {
                      "type": "string"
                    },
                    "requested_seconds": {
                      "type": "number"
                    },
                    "result_available": {
                      "type": "boolean",
                      "description": "成片当前是否可下载"
                    },
                    "result_expires_at": {
                      "type": "integer",
                      "format": "int64",
                      "nullable": true,
                      "description": "取片截止时间，Unix 秒。长期保留的成片没有截止时间。"
                    },
                    "continuable_until": {
                      "type": "integer",
                      "format": "int64",
                      "nullable": true,
                      "description": "可续拍截止时间，Unix 秒"
                    }
                  },
                  "required": [
                    "id",
                    "status"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/download": {
      "get": {
        "operationId": "getVideoDownload",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "临时下载凭据，下载时不要发送站点密钥",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string",
                          "format": "uri"
                        }
                      },
                      "required": [
                        "url"
                      ]
                    },
                    "sha256": {
                      "type": "string"
                    },
                    "bytes": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "result"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "取片期限已过或文件已移除"
          }
        }
      }
    },
    "/wallet": {
      "get": {
        "operationId": "getCredits",
        "responses": {
          "200": {
            "description": "创作点数",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "available": {
                      "type": "number"
                    },
                    "held": {
                      "type": "number"
                    },
                    "spent": {
                      "type": "number"
                    }
                  },
                  "required": []
                }
              }
            }
          }
        }
      }
    },
    "/assets": {
      "post": {
        "operationId": "prepareReferenceUpload",
        "summary": "领取一次性 PUT 地址并保存素材编号",
        "description": "将文件 PUT 到 upload.url，Content-Type 使用 application/octet-stream，仅对本站请求发送画布密钥。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "image",
                      "audio",
                      "video"
                    ]
                  },
                  "bytes": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "sha256": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                },
                "required": [
                  "kind",
                  "bytes",
                  "sha256"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "素材已登记",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "pattern": "^[0-9a-f]{32}$"
                    },
                    "upload": {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string",
                          "format": "uri"
                        }
                      },
                      "required": [
                        "url"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "upload"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}/cancel": {
      "post": {
        "operationId": "cancelQueuedVideo",
        "summary": "取消自己的排队镜头",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "已取消"
          },
          "409": {
            "description": "订单已开始处理，请查看返回的状态"
          }
        }
      }
    }
  }
}
