通用开放接口Apps API
POST /v1/apps/tasks
POST
/v1/apps/tasks提交生成任务。外层请求结构统一;inputs 内容随应用变化。
提交生成任务。外层请求结构统一;inputs 内容随应用变化。
鉴权:Bearer Token(完整)
Content-Type:application/json(也支持与 C 端一致的 multipart/form-data 上传文件)
统一请求结构
{ "app_code": "self_face_swap_v3", "inputs": {}}| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
app_code | string | 是 | 应用编码,来自 GET /v1/apps |
inputs | object | 是* | 业务入参;键名、类型、是否必填由该应用 input_schema 决定 |
关于 inputs(按应用差异)
- 不要假设所有应用使用同一套字段名。
- 创建前请确认目标应用在后台配置的入参(控件角色、
param_name、是否必填、计费时长来源等)。 - 素材建议使用可公网访问的
http(s)URL;服务端下载时仍受 SSRF / 域名策略约束。 - Token 限定额度时:若预扣金额大于 Token 剩余额度,即使钱包余额充足也会失败。
- 下方为公开
inputs示例(不含部分敏感应用);字段名以线上应用配置为准。
各应用 inputs 示例(由数据库生成)
以下示例根据已上架应用的
input_schema、默认素材路径等自动生成。字段名以线上配置为准;占位 URL(example.com)请替换为真实可访问素材。
共 7 个已上架应用。
1.视频角色替换
self_video_to_video_mix_v4
请求结构:
{ "app_code": "self_video_to_video_mix_v4", "inputs": { "face_image": "https://example.com/apps-demo/self_video_to_video_mix_v4/face_image.png", "height": "sample_height", "source_video": "https://example.com/apps-demo/self_video_to_video_mix_v4/source_video.mp4", "width": "sample_width" }}参数说明:
| 字段 | 标题 | 类型 | 必填 |
|---|---|---|---|
source_video | 原视频 | string | 是 |
face_image | 人脸图 | string | 是 |
width | 宽度 | string | 是 |
height | 高度 | string | 是 |
2.图片角色替换
self_face_swap_v3
请求结构:
{ "app_code": "self_face_swap_v3", "inputs": { "face_image": "https://example.com/apps-demo/self_face_swap_v3/face_image.png", "original_image": "https://example.com/apps-demo/self_face_swap_v3/original_image.png" }}参数说明:
| 字段 | 标题 | 类型 | 必填 |
|---|---|---|---|
original_image | 原图 | string | 是 |
face_image | 人脸图 | string | 是 |
3.MiniMax H3 Video Character Replacement
self_minimax_h3_video_swap_v1
请求结构:
{ "app_code": "self_minimax_h3_video_swap_v1", "inputs": { "ref_images": "https://example.com/apps-demo/self_minimax_h3_video_swap_v1/ref_images.png", "short_side": "480", "source_video": "https://example.com/apps-demo/self_minimax_h3_video_swap_v1/source_video.mp4" }}参数说明:
| 字段 | 标题 | 类型 | 必填 |
|---|---|---|---|
source_video | 源视频 | string | 是 |
ref_images | 目标角色参考图 | array | 是 |
prompt | 提示词 | string | 否 |
short_side | Short Side | string | 是 |
4.Face Swap – Chibi Edition
self_face_swap
请求结构:
{ "app_code": "self_face_swap", "inputs": { "face_image": "https://example.com/apps-demo/self_face_swap/face_image.png", "ref_image": "https://example.com/apps-demo/self_face_swap/ref_image.png" }}参数说明:
| 字段 | 标题 | 类型 | 必填 |
|---|---|---|---|
ref_image | Reference image | string | 是 |
face_image | 人脸图 | string | 是 |
5.Virtual Try-On
self_try_on
请求结构:
{ "app_code": "self_try_on", "inputs": { "clothing_images": "https://example.com/apps-demo/self_try_on/clothing_images.png", "old_image": "https://example.com/apps-demo/self_try_on/old_image.png" }}参数说明:
| 字段 | 标题 | 类型 | 必填 |
|---|---|---|---|
old_image | Old Image | string | 是 |
clothing_images | Clothing Images | array | 是 |
6.Character Composer
self_role_synthesize
请求结构:
{ "app_code": "self_role_synthesize", "inputs": { "costume_image": "https://example.com/apps-demo/self_role_synthesize/costume_image.png", "portrait_image": "https://example.com/apps-demo/self_role_synthesize/portrait_image.png", "pose_image": "https://example.com/apps-demo/self_role_synthesize/pose_image.png", "prompt": "sample_prompt", "style_preset": "none" }}参数说明:
| 字段 | 标题 | 类型 | 必填 |
|---|---|---|---|
portrait_image | Portrait Image | string | 是 |
costume_image | Costume Image | string | 是 |
pose_image | Pose Image | string | 是 |
style_preset | Style preset | string | 是 |
prompt | 提示词 | string | 是 |
7.Video Cleaner – Watermark & Subtitle Remover
self_video_clear_v1
请求结构:
{ "app_code": "self_video_clear_v1", "inputs": { "source_video": "https://example.com/apps-demo/self_video_clear_v1/source_video.mp4" }}参数说明:
| 字段 | 标题 | 类型 | 必填 |
|---|---|---|---|
source_video | 原视频 | string | 是 |
请求示例(curl)
curl https://www.mangogo.ai/v1/apps/tasks \ -H "Authorization: Bearer sk-xxx" \ -H "Content-Type: application/json" \ -d '{ "app_code": "self_face_swap_v3", "inputs": { "face_image": "https://assets.guid.ai/guid/users/32/2026/09/face.jpg", "original_image": "https://assets.guid.ai/guid/users/32/2026/09/base.jpg" } }'成功响应
字段顺序固定:
{ "code": 0, "data": { "task_id": "c1c51c886bdd2e39", "task_no": "d5lsag6npfQgth4z", "app_code": "self_face_swap_v3", "status": "queued", "status_label": "Task Queued" }, "message": "", "success": true}data 字段 | 类型 | 说明 |
|---|---|---|
task_id | string | 平台任务 ID,用于查询 |
task_no | string | 业务单号,也可用于查询 |
app_code | string | 应用编码 |
status | string | 任务状态,见下文 |
status_label | string | 状态展示文案 |
error_code | string | 创建即失败时可能出现 |
error_message | string | 创建即失败时可能出现 |
创建成功后请使用 GET /v1/apps/tasks/{task_id} 轮询,直至 completed / failed / cancelled。
任务状态
status | 说明 |
|---|---|
pending | 已受理,待提交上游 |
queued | 排队中 |
processing | 处理中 |
completed | 已完成 |
failed | 失败 |
cancelled | 已取消 |
终态:completed / failed / cancelled。建议轮询间隔 2–5 秒,并设置合理超时。
常见错误
| 场景 | 典型 message |
|---|---|
| 未提供 / 无效 Token | 鉴权相关错误(HTTP 401) |
| 用户或 Token 额度不足 | 额度不足 / Insufficient quota |
app_code 无效或未上架 | 应用不可用相关错误 |
inputs 不符合 schema | 参数无效相关错误 |
| 任务不存在或非本人 | 未找到 / 未授权 |