| 接口 | 用途 | 使用时机 |
|---|---|---|
POST /mj/submit/imagine | 文生图 | 所有流程的起点 |
GET /mj/task/{id}/fetch | 查询任务状态 & 获取按钮 | 每次提交后轮询 |
POST /mj/submit/action | 点击按钮(放大、变体、缩放等) | 对图片进行操作时 |
POST /mj/submit/modal | 提交额外输入 | 仅当状态为 MODAL 时 |
┌─────────────────────────────────────────────────────────────────────────────┐
│ MIDJOURNEY API 工作流程 │
└─────────────────────────────────────────────────────────────────────────────┘
┌──────────────────┐
│ POST /submit/ │ ← 第1步:提交 prompt,获取 task_id
│ imagine │
└────────┬─────────┘
│ 返回: { "result": "task_id_1" }
▼
┌──────────────────┐
│ GET /task/{id}/ │ ← 第2步:轮询直到 status = "SUCCESS"
│ fetch │
└────────┬─────────┘
│ 返回: imageUrl + buttons[] (U1,U2,U3,U4,V1,V2,V3,V4,🔄)
▼
┌──────────────────┐
│ POST /submit/ │ ← 第3步:使用 customId 点击按钮
│ action │
└────────┬─────────┘
│ 返回: { "result": "task_id_2" }
▼
┌──────────────────┐
│ GET /task/{id}/ │ ← 第4步:轮询新任务
│ fetch │
└────────┬─────────┘
│
├─── status = "SUCCESS" → 完成!获取 imageUrl
│
└─── status = "MODAL" → 需要额外输入(见第5步)
│
▼
┌──────────────────┐
│ POST /submit/ │ ← 第5步:提交蒙版/提示词
│ modal │
└────────┬─────────┘
│ 返回: { "result": "task_id_3" }
▼
┌──────────────────┐
│ GET /task/{id}/ │ ← 第6步:轮询直到 SUCCESS
│ fetch │
└──────────────────┘buttons 数组。每个按钮都有一个 customId,用于触发下一个操作。/mj/task/{id}/fetch 响应示例:{
"status": "SUCCESS",
"imageUrl": "https://api.deerapi.com/mj/image/xxx",
"buttons": [
{ "customId": "MJ::JOB::upsample::1::abc123", "label": "U1" },
{ "customId": "MJ::JOB::upsample::2::abc123", "label": "U2" },
{ "customId": "MJ::JOB::variation::1::abc123", "label": "V1" },
{ "customId": "MJ::JOB::reroll::0::abc123", "emoji": "🔄" }
]
}customId 不是固定值,每个任务都不同。必须从 buttons 数组中获取。| 按钮 | customId 格式 | 操作 | 结果 |
|---|---|---|---|
| U1-U4 | MJ::JOB::upsample::1::xxx | 放大单张图片 | 高清单图 |
| V1-V4 | MJ::JOB::variation::1::xxx | 生成变体 | 新的 4 宫格 |
| 🔄 | MJ::JOB::reroll::0::xxx::SOLO | 重新生成 | 新的 4 宫格 |
| 按钮 | 需要 Modal? |
|---|---|
| Upscale (Subtle) / Upscale (2x) | ❌ 否 |
| Upscale (Creative) / Upscale (4x) | ❌ 否 |
| Vary (Subtle) 🪄 | ❌ 否 |
| Vary (Strong) 🪄 | ❌ 否 |
| Vary (Region) 🖌️ | ✅ 是(需要蒙版) |
| Zoom Out 2x / 1.5x 🔍 | ❌ 否 |
| Custom Zoom 🔍 | ✅ 是(需要提示词) |
| ⬅️➡️⬆️⬇️ Pan | ❌ 否 |
| Animate 🎞️ | ❌ 否 |
| 🔄 Reroll | ❌ 否 |
注意: 按钮名称和 customId格式可能因 prompt 中指定的 MJ 版本而异(如--v 6.1vs--v 5.2)。务必从 API 响应中读取按钮。
{ "code": 1, "result": "1768464763141701" }{
"status": "SUCCESS",
"imageUrl": "https://api.deerapi.com/mj/image/1768464763141701",
"buttons": [
{ "customId": "MJ::JOB::upsample::1::5f20922e-xxx", "label": "U1" },
{ "customId": "MJ::JOB::upsample::2::5f20922e-xxx", "label": "U2" },
...
]
}{ "code": 1, "result": "1768464800000000" }