{
  "openapi": "3.0.3",
  "info": {
    "title": "TiKo API",
    "version": "2026.10.04",
    "description": "通过 Bearer API Key 创建、查询、播放和下载视频生成任务。调用方应先 GET /models 读取实时模型和价格。"
  },
  "servers": [{"url": "http://127.0.0.1:8787/openapi/v1"}],
  "security": [{"bearerAuth": []}],
  "paths": {
    "/models": {
      "get": {
        "summary": "读取模型和价格",
        "operationId": "listModels",
        "responses": {"200": {"description": "模型列表"}}
      }
    },
    "/account": {
      "get": {
        "summary": "读取账号积分余额",
        "operationId": "getAccount",
        "responses": {"200": {"description": "账号信息"}}
      }
    },
    "/videos": {
      "post": {
        "summary": "创建视频生成任务",
        "operationId": "createVideo",
        "parameters": [{
          "name": "Idempotency-Key",
          "in": "header",
          "required": false,
          "schema": {"type": "string", "minLength": 8, "maxLength": 100}
        }],
        "requestBody": {
          "required": true,
          "content": {"application/json": {"schema": {"$ref": "#/components/schemas/VideoCreateRequest"}}}
        },
        "responses": {
          "202": {"description": "任务已创建"},
          "400": {"description": "参数错误"},
          "402": {"description": "积分不足"},
          "503": {"description": "模型暂不可用"}
        }
      }
    },
    "/videos/{id}": {
      "get": {
        "summary": "查询视频任务",
        "operationId": "getVideo",
        "parameters": [{"$ref": "#/components/parameters/TaskId"}],
        "responses": {"200": {"description": "任务状态"}}
      }
    },
    "/videos/{id}/content": {
      "get": {
        "summary": "读取或下载视频内容",
        "operationId": "getVideoContent",
        "parameters": [{"$ref": "#/components/parameters/TaskId"}],
        "responses": {"200": {"description": "视频文件"}, "206": {"description": "视频分段"}}
      }
    },
    "/files": {
      "post": {
        "summary": "上传 Base64 图片参考素材",
        "operationId": "uploadFile",
        "requestBody": {
          "required": true,
          "content": {"application/json": {"schema": {"type": "object", "required": ["image_b64"], "properties": {"image_b64": {"type": "string", "description": "data:image/...;base64,..."}}}}}
        },
        "responses": {"200": {"description": "素材已保存"}}
      }
    }
  },
  "components": {
    "securitySchemes": {"bearerAuth": {"type": "http", "scheme": "bearer", "bearerFormat": "SUBSITE_API_KEY_EXAMPLE" }},
    "parameters": {"TaskId": {"name": "id", "in": "path", "required": true, "schema": {"type": "string"}}},
    "schemas": {
      "VideoCreateRequest": {
        "type": "object",
        "required": ["model", "prompt"],
        "properties": {
          "model": {"type": "string", "enum": ["seedance-2.5-workflow", "seedance-2.5", "seedance-2.0", "minimaxh3"]},
          "prompt": {"type": "string", "minLength": 1},
          "duration": {"type": "integer", "description": "具体可用值以 GET /models 为准"},
          "seconds": {"type": "integer"},
          "aspect_ratio": {"type": "string", "example": "16:9"},
          "ratio": {"type": "string", "example": "16:9"},
          "resolution": {"type": "string", "example": "720p"},
          "mode": {"type": "string", "example": "text-to-video"},
          "attachments": {"type": "array", "items": {"type": "object"}}
        }
      }
    }
  }
}
