{
  "openapi": "3.1.0",
  "info": {
    "title": "MiniMax API",
    "description": "MiniMax video generation and file management API",
    "license": {
      "name": "MIT"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
     
      "url": "https://api.minimaxi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/video_generation": {
      "post": {
        "summary": "Video Generation",
        "operationId": "videoGeneration",
        "tags": ["Video"],
        "parameters": [
          {
            "name": "Content-Type",
            "in": "header",
            "required": true,
            "description": "请求体的媒介类型，请设置为 `application/json` 确保请求数据的格式为 JSON.",
            "schema": {
              "type": "string",
              "enum": ["application/json"],
              "default": "application/json"
            }
          }
        ],
        "requestBody": {
          "description": "",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoGenerationReq"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoGenerationResp"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "VideoGenerationReq": {
        "type": "object",
        "required": ["model", "prompt"],
        "properties": {
          "model": {
            "type": "string",
            "description": "模型名称。可用值：\n `MiniMax-Hailuo-2.3`, `MiniMax-Hailuo-02`, `T2V-01-Director`, `T2V-01`.",
            "enum": ["MiniMax-Hailuo-2.3", "MiniMax-Hailuo-02", "T2V-01-Director", "T2V-01"]
          },
          "prompt": {
            "type": "string",
            "description": "视频的文本描述，最大 2000 字符。对于 `MiniMax-Hailuo-2.3`、`MiniMax-Hailuo-02` 和 `*-Director` 系列模型，支持使用 `[指令]` 语法进行运镜控制。\n可在 prompt 中通过 [指令] 格式添加运镜指令，以实现精确的镜头控制。\n\n- 支持 15 种运镜指令的指令:\n\t - 左右移: [左移], [右移]\n\t - 左右摇: [左摇], [右摇]\n\t - 推拉: [推进], [拉远]\n\t - 升降: [上升], [下降]\n\t - 上下摇: [上摇], [下摇]\n\t - 变焦: [变焦推近], [变焦拉远]\n\t - 其他: [晃动], [跟随], [固定]\n\n - 使用规则:\n\t - 组合运镜: 同一组 [] 内的多个指令会同时生效，如 [左摇,上升]，建议组合不超过 3 个\n\t - 顺序运镜: prompt 中前后出现的指令会依次生效，如 \"...[推进], 然后...[拉远]\"\n\t - 自然语言: 也支持通过自然语言描述运镜，但使用标准指令能获得更准确的响应 "
          },
          "prompt_optimizer": {
            "type": "boolean",
            "description": "是否自动优化 `prompt`，默认为 `true`。设为 `false` 可进行更精确的控制"
          },
          "fast_pretreatment": {
            "type": "boolean",
            "description": "是否缩短 `prompt_optimizer` 的优化耗时，默认为 false。仅对 `MiniMax-Hailuo-2.3` 和 `MiniMax-Hailuo-02` 模型生效。"
          },
          "duration": {
            "type": "integer",
            "description": "视频时长（秒），默认值为 6。其可用值与模型和分辨率相关：\n| Model |  720P |768P | 1080P |\n| :--- |:--- |:--- | :--- |\n| MiniMax-Hailuo-2.3 | - | `6` 或 `10` | `6` |\n| MiniMax-Hailuo-02 | - | `6` 或 `10` | `6` |\n| 其他模型 | `6` | - |`6` |  "
          },
          "resolution": {
            "type": "string",
            "description": "视频分辨率。其可用值与模型相关：\n| Model | 6s | 10s |\n| :--- | :--- | :--- |\n| MiniMax-Hailuo-2.3 |  `768P` (默认), `1080P` |  `768P` (默认) |\n| MiniMax-Hailuo-02 |  `768P` (默认), `1080P` |  `768P` (默认) |\n| 其他模型 | `720P` (默认) | 不支持 |",
            "enum": [ "720P", "768P", "1080P"]
          },
          "callback_url": {
            "type": "string",
            "description": "接收任务状态更新通知的回调 URL。支持通过 callback_url 参数可以配置回调，以接收任务状态的更新的异步通知。\n\n地址验证：配置后，MiniMax 服务器会向 callback_url 发送一个 POST 请求，请求体中包含 challenge 字段。服务端需要在 3 秒内原样返回该 challenge 值以完成验证\n状态更新：验证成功后，每当任务状态变更时，MiniMax 都会向该 URL 推送最新的任务状态。推送的数据结构与调用查询视频生成任务接口的响应体一致\n\n回调返回的\"status\"包括以下状态：\n- `\"processing\"` - 生成中\n- `\"success\"` - 成功\n- `\"failed\"` - 失败\n\n```python\nfrom fastapi import FastAPI, HTTPException, Request\r\nimport json\r\n\r\napp = FastAPI()\r\n\r\n@app.post(\"/get_callback\")\r\nasync def get_callback(request: Request):\r\n    try:\r\n        json_data = await request.json()\r\n        challenge = json_data.get(\"challenge\")\r\n        if challenge is not None:\r\n            # Validation request, echo back challenge\r\n            return {\"challenge\": challenge}\r\n        else:\r\n            # Status update request, handle accordingly\r\n            # {\r\n            #     \"task_id\": \"115334141465231360\",\r\n            #     \"status\": \"success\",\r\n            #     \"file_id\": \"205258526306433\",\r\n            #     \"base_resp\": {\r\n            #         \"status_code\": 0,\r\n            #         \"status_msg\": \"success\"\r\n            #     }\r\n            # }\r\n            return {\"status\": \"success\"}\r\n    except Exception as e:\r\n        raise HTTPException(status_code=500, detail=str(e))\r\n\r\nif __name__ == \"__main__\":\r\n    import uvicorn\r\n    uvicorn.run(\r\n        app,  # 必选\r\n        host=\"0.0.0.0\",  # 必选\r\n        port=8000,  # 必选，端口可设置\r\n        # ssl_keyfile=\"yourname.yourDomainName.com.key\",  # 可选，看是否开启ssl\r\n        # ssl_certfile=\"yourname.yourDomainName.com.key\",  # 可选，看是否开启ssl\r\n    )\n```"
          },
          "aigc_watermark": {
            "type": "boolean",
            "description": "是否在生成的视频中添加水印，默认为 `false`"
          }
        },
        "example": {
          "model": "MiniMax-Hailuo-2.3",
          "prompt": "A man picks up a book [Pedestal up], then reads [Static shot].",
          "duration": 6,
          "resolution": "1080P"
        }
      },
      "VideoGenerationResp": {
        "type": "object",
        "properties": {
          "task_id": {
            "type": "string",
            "description": "视频生成任务的 ID，用于后续查询任务状态"
          },
          "base_resp": {
            "$ref": "#/components/schemas/BaseResp"
          }
        },
        "example": {
          "task_id": "106916112212032",
          "base_resp": {
            "status_code": 0,
            "status_msg": "success"
          }
        }
      },
      "BaseResp": {
        "type": "object",
        "properties": {
          "status_code": {
            "type": "integer",
            "description": "状态码及其分别含义如下：\n- 0：请求成功\n- 1002：触发限流，请稍后再试\n- 1004：账号鉴权失败，请检查 API-Key 是否填写正确\n- 1008：账号余额不足\n- 1026：视频描述涉及敏感内容，请调整\n- 2013：传入参数异常，请检查入参是否按要求填写\n- 2049：无效的api key，请检查api key\n\n更多内容可查看[错误码列表](/api-reference/errorcode)  "
          },
          "status_msg": {
            "type": "string",
            "description": "具体错误详情"
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
         "description": "`HTTP: Bearer Auth`\n - Security Scheme Type: http\n - HTTP Authorization Scheme: Bearer API_key，用于验证账户信息，可在 [账户管理>接口密钥](https://platform.minimaxi.com/user-center/basic-information/interface-key) 中查看。"
      }
    }
  }
}
