{
  "openapi": "3.0.3",
  "info": {
    "title": "Pense Video API",
    "version": "1.0.0",
    "description": "使用 MX Canvas 账号积分调用视频生成服务。"
  },
  "servers": [
    {
      "url": "https://api.pense.cn/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/models": {
      "get": {
        "summary": "获取可用视频模型",
        "description": "仅返回 MX Canvas 后台已设置价格且启用“向用户展示”的模型和分辨率。隐藏模型即使通过手工构造请求提交，也会被服务端拒绝。",
        "responses": {
          "200": {
            "description": "模型列表"
          }
        }
      }
    },
    "/account/balance": {
      "get": {
        "summary": "查询账户积分",
        "responses": {
          "200": {
            "description": "账户余额"
          }
        }
      }
    },
    "/videos/generations": {
      "post": {
        "summary": "创建视频生成任务",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoGenerationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "任务已创建"
          }
        }
      }
    },
    "/videos/tasks/{task_id}": {
      "get": {
        "summary": "查询视频任务",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "任务状态及结果"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "pense_sk_xxx"
      }
    },
    "schemas": {
      "Reference": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "audio"
            ]
          },
          "mime": {
            "type": "string"
          }
        }
      },
      "VideoGenerationRequest": {
        "type": "object",
        "required": [
          "model",
          "prompt",
          "duration",
          "resolution"
        ],
        "properties": {
          "model": {
            "type": "string",
            "example": "release/seedance-2.0"
          },
          "prompt": {
            "type": "string"
          },
          "duration": {
            "type": "number",
            "example": 5
          },
          "ratio": {
            "type": "string",
            "example": "16:9"
          },
          "resolution": {
            "type": "string",
            "example": "720p"
          },
          "references": {
            "type": "array",
            "description": "参考素材。穗禾首尾帧模式下，前两张 image 会按顺序作为 first_frame 和 end_frame。",
            "items": {
              "$ref": "#/components/schemas/Reference"
            }
          },
          "extensions": {
            "type": "object",
            "description": "模型扩展参数。穗禾首尾帧使用 {\"function_mode\":\"first_last_frames\"}。",
            "properties": {
              "function_mode": {
                "type": "string",
                "enum": [
                  "auto",
                  "first_last_frames"
                ],
                "description": "穗禾视频模式。first_last_frames 表示首尾帧。"
              }
            },
            "additionalProperties": true
          }
        }
      }
    }
  }
}
