Midjorney调用最佳实践
DeerAPI Midjourney API 文档
headers = {"Authorization": "sk-hjbazhiawxxxxxxxxxx"}
1. 提交 Imagine(绘图)任务
接口信息
请求示例
{
"base64Array": [],
"notifyHook": "",
"prompt": "Cat",
"state": ""
}
请求参数
参数名称 | 参数说明 | 是否必须 | 数据类型 |
---|---|---|---|
base64Array | 垫图base64数组 | 否 | array string |
prompt | 提示词 | 是 | string |
state | 自定义参数 | 否 | string |
响应状态
状态码 | 说明 |
---|---|
200 | OK |
201 | Created |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
响应参数
参数名称 | 参数说明 | 类型 |
---|---|---|
code | 状态码: 1(提交成功), 21(已存在), 22(排队中), 4(程序内部错误) | integer(int32) |
description | 描述 | string |
properties | 扩展字段 | object |
result | 任务ID | string |
响应示例
{
"code": 1,
"description": "提交成功",
"properties": {},
"result": 1320098173412546
}
2. 执行动作
接口信息
3. 绘图变化
接口信息
请求示例
{
"action": "UPSCALE",
"index": 1,
"notifyHook": "",
"state": "",
"taskId": "1320098173412546"
}
请求参数
参数名称 | 参数说明 | 是否必须 | 数据类型 |
---|---|---|---|
action | UPSCALE(放大); VARIATION(变换); REROLL(重新生成) | 是 | string |
index | 序号(1~4), action为UPSCALE,VARIATION时必传 | 否 | integer(int32) |
notifyHook | 回调地址, 为空时使用全局notifyHook | 否 | string |
state | 自定义参数 | 否 | string |
taskId | 任务ID | 是 | string |
响应状态
状态码 | 说明 |
---|---|
200 | OK |
201 | Created |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
响应参数
参数名称 | 参数说明 | 类型 |
---|---|---|
code | 状态码: 1(提交成功), 21(已存在), 22(排队中), other(错误) | integer(int32) |
description | 描述 | string |
properties | 扩展字段 | object |
result | 任务ID | string |
响应示例
{
"code": 1,
"description": "提交成功",
"properties": {},
"result": 1320098173412546
}
4. 提交Modal (局部重绘、Zoom)
接口信息
请求示例
{
"maskBase64": "",
"prompt": "",
"taskId": "14001934816969359"
}
请求参数
参数名称 | 参数说明 | 是否必须 | 数据类型 |
---|---|---|---|
maskBase64 | 局部重绘的蒙版base64 | 否 | string |
prompt | 提示词 | 否 | string |
taskId | 任务id | 是 | string |
响应状态
状态码 | 说明 |
---|---|
200 | OK |
201 | Created |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
响应参数
参数名称 | 参数说明 | 类型 |
---|---|---|
code | 状态码: 1(提交成功), 21(已存在), 22(排队中), other(错误) | integer(int32) |
description | 描述 | string |
properties | 扩展字段 | object |
result | 任务ID | string |
响应示例
{
"code": 1,
"description": "提交成功",
"properties": {},
"result": 1320098173412546
}
5. 指定 ID 获取任务
接口信息
请求参数
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
---|---|---|---|---|
id | 任务ID | path | 否 | string |
响应状态
状态码 | 说明 |
---|---|
200 | OK |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
响应参数
参数名称 | 参数说明 | 类型 |
---|---|---|
action | 可用值:UPSCALE,VARIATION,REROLL,DESCRIBE,BLEND | string |
description | 任务描述 | string |
failReason | 失败原因 | string |
finishTime | 结束时间 | integer(int64) |
id | 任务ID | string |
imageUrl | 图片url | string |
progress | 任务进度 | string |
prompt | 提示词 | string |
promptEn | 提示词-英文 | string |
startTime | 开始执行时间 | integer(int64) |
state | 自定义 参数 | string |
status | 任务状态,可用值:SUBMITTED,IN_PROGRESS,FAILURE,SUCCESS | string |
submitTime | 提交时间 | integer(int64) |
响应示例
{
"id": "1712310326047513",
"action": "UPSCALE",
"customId": "",
"botType": "",
"prompt": "a lovely Japan countryside --niji 6 --ar 16:9",
"promptEn": "a lovely Japan countryside --niji 6 --ar 16:9",
"description": "Submit success",
"state": "",
"submitTime": 1712310326047,
"startTime": 1712310328336,
"finishTime": 1712310329602,
"imageUrl": "https://api.deerapi.com/mj/image/1712310326047513",
"status": "SUCCESS",
"progress": "100%",
"failReason": "",
"buttons": [
{
"customId": "MJ::JOB::upsample_v6_2x_subtle::1::125fd761-3d07-4252-8513-8a07dce51ce7::SOLO",
"emoji": "upscale_1",
"label": "Upscale (Subtle)",
"type": 2,
"style": 2
},
// ... 其他按钮配置
],
"maskBase64": "",
"properties": {
"finalPrompt": "a lovely Japan countryside --niji 6 --ar 16:9",
"finalZhPrompt": ""
}
}