局部重绘
- 两步流程:/action 起,/modal 完成
- 第一步的任务停在 MODAL 等待参数
- 蒙版透明区域即重绘范围
认证
所有接口均使用 Bearer Token 进行认证。获取 API Key:访问控制台 创建。请求时在请求头中添加:
All endpoints authenticate with a Bearer token. Create a key in the console and add it to the request header:
两步流程
| 步骤 | 端点 | 作用 |
|---|---|---|
| 1 | POST /mj/submit/action | 传 Vary (Region) 的 customId,任务进入 MODAL 状态 |
| 2 | POST /mj/submit/modal | 传 taskId、prompt、maskBase64 完成重绘 |
第一步本身不出图。任务停在 MODAL 时 buttons 为空,必须补第二步才会继续执行。
| Step | Endpoint | Purpose |
|---|---|---|
| 1 | POST /mj/submit/action | Send the Vary (Region) customId; the task enters MODAL |
| 2 | POST /mj/submit/modal | Send taskId, prompt, maskBase64 to complete the edit |
Step one produces no image. In MODAL the task has no buttons; only step two resumes it.
请求参数
第一步返回的任务 ID(/modal);或父任务 ID(/action)。
描述重绘区域里要出现的内容。省略时沿用父任务的提示词。
蒙版图片的 Base64,透明区域表示要重绘的部分。
为 true 时返回官方链接,默认 false。
The task ID from step one (/modal), or the parent task ID (/action).
What should appear in the region. Omit to reuse the parent prompt.
Base64 of the mask; transparent pixels are the area to redraw.
Return official links; default false.
蒙版怎么画
| 蒙版像素 | 含义 |
|---|---|
| 透明(alpha = 0) | 这块会被重绘 |
| 不透明(alpha = 255) | 这块保持原样 |
常见做法是在 Photoshop 或 Figma 里把要改的区域擦成透明,其余保持白色不透明,导出 PNG 后转 Base64。
蒙版尺寸必须与底图完全一致,差一个像素都会被判为非法。
| Mask pixel | Meaning |
|---|---|
| Transparent (alpha = 0) | Redrawn |
| Opaque (alpha = 255) | Left unchanged |
The usual recipe: erase the target area to transparent in Photoshop or Figma, keep the rest opaque white, export PNG, then base64 it.
The mask must match the base image exactly; a one-pixel difference is rejected.
错误码
| HTTP | 含义 |
|---|---|
| 200 | 已受理,看 code |
| 401 | Token 缺失或无效 |
| 429 | 触发限流 |
常见失败:maskBase64 缺失或尺寸与底图不一致;taskId 不是 MODAL 状态;父任务还是四宫格。
| HTTP | Meaning |
|---|---|
| 200 | Accepted; check code |
| 401 | Token missing or invalid |
| 429 | Rate limit hit |
Common failures: a missing mask or one that doesn't match the base size; a taskId not in MODAL; a parent that's still a grid.
使用示例
先对放大后的单图执行 Vary (Region) 拿到 MODAL 任务,再用 /mj/submit/modal 补提示词与蒙版。
Run Vary (Region) on an upscaled image to get a MODAL task, then send the prompt and mask to /mj/submit/modal.