通用约定与任务查询
- 动作由路径决定,没有统一的 action 字段
- 提交返回任务 ID,用 /mj/task 查询
- 时间字段是毫秒
认证
所有接口均使用 Bearer Token 进行认证。获取 API Key:访问控制台 创建。请求时在请求头中添加:
All endpoints authenticate with a Bearer token. Create a key in the console and add it to the request header:
路径约定
动作由路径决定,没有统一的 action 字段:
| 动作 | 路径 |
|---|---|
| 文生图 | POST /mj/submit/imagine |
| 混图 | POST /mj/submit/blend |
| 反推提示词 | POST /mj/submit/describe |
| 执行按钮动作(放大、变体、扩图) | POST /mj/submit/action |
| 弹窗参数(局部重绘、自定义缩放) | POST /mj/submit/modal |
| 图生视频 | POST /mj/submit/video |
| 图片编辑 / 重绘 | POST /mj/submit/edits |
| 材质重绘 | POST /mj/submit/retexture |
| 上传图片到 Discord | POST /mj/submit/upload-discord-images |
| 查询单个任务 | GET /mj/task/{id}/fetch |
| 批量查询任务 | POST /mj/task/list-by-condition |
| 获取任务 Seed | GET /mj/task/{id}/image-seed |
| 代理任务图片 | GET /mj/image/{id} |
也支持带模式前缀的写法 POST /{mode}/mj/submit/{action},{mode} 由渠道配置决定;不确定时用不带前缀的路径。
The action is carried by the path; there is no shared action field:
| Action | Path |
|---|---|
| Text to image | POST /mj/submit/imagine |
| Blend | POST /mj/submit/blend |
| Describe | POST /mj/submit/describe |
| Button actions (upscale, variation, zoom) | POST /mj/submit/action |
| Modal parameters (region edit, custom zoom) | POST /mj/submit/modal |
| Image to video | POST /mj/submit/video |
| Image edit / redraw | POST /mj/submit/edits |
| Retexture | POST /mj/submit/retexture |
| Upload to Discord | POST /mj/submit/upload-discord-images |
| Fetch one task | GET /mj/task/{id}/fetch |
| Query several tasks | POST /mj/task/list-by-condition |
| Task seed | GET /mj/task/{id}/image-seed |
| Proxy task image | GET /mj/image/{id} |
A mode-prefixed form POST /{mode}/mj/submit/{action} also works; {mode} comes from the channel config. Use the unprefixed path when unsure.
提交结果
所有提交接口返回同一种信封:
{
"code": 1,
"description": "提交成功",
"result": "1320098173412546"
}code(integer) —1表示成功,22表示排队中,其他值为错误。description(string) — 状态描述,失败时是原因。result(string) — 任务 ID,后续查询与动作都用它。
Every submit endpoint returns the same envelope:
{
"code": 1,
"description": "提交成功",
"result": "1320098173412546"
}code(integer) —1means success,22means queued, anything else is an error.description(string) — a status description; the failure reason when it failed.result(string) — the task ID, used for later queries and actions.
任务对象
查询接口返回任务对象,关键字段如下:
id/status/progress— 任务 ID、状态、进度(带百分号)。imageUrl/imageUrls— 主图与图片列表,四宫格时 4 张。action— 任务类型,如IMAGINE、UPSCALE。prompt/promptEn— 原始与规范化后的提示词。failReason— 失败原因,仅失败时非空。buttons— 可执行动作,含customId、label、emoji。submitTime/startTime/finishTime— 毫秒时间戳。
时间字段是毫秒,不是秒。这一点和其他异步任务接口不同。
The fetch endpoints return a task object with these key fields:
id/status/progress— task ID, status, and a percent string.imageUrl/imageUrls— the main image and the list; four for a grid.action— task type such asIMAGINEorUPSCALE.prompt/promptEn— the original and normalized prompt.failReason— the failure reason, empty on success.buttons— available actions withcustomId,label,emoji.submitTime/startTime/finishTime— milliseconds.
Time fields are milliseconds, not seconds — unlike the other async task endpoints.
任务状态
| 状态 | 含义 |
|---|---|
NOT_START | 未开始 |
SUBMITTED | 已提交,排队中 |
MODAL | 等待弹窗参数,需调 /mj/submit/modal 补参数 |
IN_PROGRESS | 执行中 |
SUCCESS | 成功 |
FAILURE | 失败,看 failReason |
CANCEL | 已取消 |
| Status | Meaning |
|---|---|
NOT_START | Not started |
SUBMITTED | Submitted and queued |
MODAL | Waiting for modal parameters via /mj/submit/modal |
IN_PROGRESS | Running |
SUCCESS | Succeeded |
FAILURE | Failed; check failReason |
CANCEL | Cancelled |
错误码
| HTTP | Meaning |
|---|---|
| 200 | Accepted. Check code; only 1 is success |
| 401 | Token missing or invalid |
| 429 | Rate limit hit |
For more status codes see Error codes and rate limits; for troubleshooting see the FAQ.
使用示例
提交后查询
imagine 返回任务 ID 后,轮询 /mj/task/{id}/fetch 直到 status 为 SUCCESS 或 FAILURE。
批量查询
一次查多个任务,适合列表页的状态刷新。
Submit then fetch
After imagine returns a task ID, poll /mj/task/{id}/fetch until status is SUCCESS or FAILURE.
Batch query
Fetch several tasks at once, handy for refreshing a list view.