Skip to content
EN

Midjourney接入向导

Midjourney接入向导

模式接入点

2种模式价格不一致:

fast模式: /mj-fast

relax模式: /mj-relax 或通过令牌设置 设置模式、返回图片代理方式

API接口类型

类型1:新任务创建

提交Imagine任务(文生图、文图生图): /mj/submit/imagine

提交Blend任务(图生图): /mj/submit/blend

提交Describe任务(图生文): /mj/submit/describe

提交Shorten任务(prompt分析): /mj/submit/shorten

类型2:任务再操作

执行动作(所有的关联按钮动作UPSCALE; VARIATION; REROLL; ZOOM等): /mj/submit/action

提交Modal(提交局部重绘、ZOOM): /mj/submit/modal

类型3:任务查询

指定ID获取任务: /mj/task/{id}/fetch

接入流程 Demo

以提交 Imagine 任务为 Demo

第一步: 提交类型1 Imagine 任务

接口说明 获取到任何ID result:1320098173412546

curl --request post \
  --url {{BASE_URL}}/fast/mj/submit/imagine \
  --header 'Authorization: Bearer sk-替换为你的key' \
  -H "Content-Type: application/json" \
  --data '{
  "base64Array": [],
  "prompt": "black cat"
}'

第二步: 根据任务ID获取任务结果

由第一步得到任务ID为 1320098173412546,得到返回结果。

curl --request GET \
  --url {{BASE_URL}}/fast/mj/task/1320098173412546/fetch \
  --header 'Authorization: Bearer sk-替换为你的key' \
  -H "Content-Type: application/json"

不断轮询查询任务接口,直到 progress 为 100%

{
    "id": "1320098173412546",
    "action": "IMAGINE",
    "prompt": "cat --v 6.1",
    "promptEn": "cat --v 6.1",
    "description": "Submit success",
    "state": "",
    "submitTime": 1741531578038,
    "startTime": 1741531580190,
    "finishTime": 1741531608566,
    "imageUrl": "https://img.innk.cc/attachments/1320066655572987907/1348306030429470862/adam_rivera4952_cat_26d56b92-4ed6-45e2-8561-563797923135.png?ex=67cefb57\u0026is=67cda9d7\u0026hm=b87e6b24e4bc3c2f1584b72154075607d6115602d0e5c7777e6637c29b8d3bd5\u0026",
    "status": "SUCCESS",
    "progress": "100%",
    "failReason": "",
    "properties": {
        "botType": "MID_JOURNEY",
        "discordChannelId": 8774786694361674000,
        "discordInstanceId": 7415633538733103000,
        "finalPrompt": "cat --v 6.1 --sref \u003chttps://s.mj.run/ktqQpnwPoPk\u003e",
        "flags": 0,
        "messageContent": "**cat --v 6.1 --sref \u003chttps://s.mj.run/ktqQpnwPoPk\u003e** - \u003c@1343445981269594182\u003e (relaxed)",
        "messageHash": "26d56b92-4ed6-45e2-8561-563797923135",
        "messageId": "1348306030706036789",
        "nonce": "1619855216344100864",
        "notifyHook": "",
        "progressMessageId": "1348305922325479495"
    },
    "buttons": [
        {
            "customId": "MJ::JOB::upsample::1::26d56b92-4ed6-45e2-8561-563797923135",
            "emoji": "",
            "label": "U1",
            "style": 2,
            "type": 2
        },
        {
            "customId": "MJ::JOB::upsample::2::26d56b92-4ed6-45e2-8561-563797923135",
            "emoji": "",
            "label": "U2",
            "style": 2,
            "type": 2
        },
        {
            "customId": "MJ::JOB::upsample::3::26d56b92-4ed6-45e2-8561-563797923135",
            "emoji": "",
            "label": "U3",
            "style": 2,
            "type": 2
        },
        {
            "customId": "MJ::JOB::upsample::4::26d56b92-4ed6-45e2-8561-563797923135",
            "emoji": "",
            "label": "U4",
            "style": 2,
            "type": 2
        },
        {
            "customId": "MJ::JOB::reroll::0::26d56b92-4ed6-45e2-8561-563797923135::SOLO",
            "emoji": "🔄",
            "label": "",
            "style": 2,
            "type": 2
        },
        {
            "customId": "MJ::JOB::variation::1::26d56b92-4ed6-45e2-8561-563797923135",
            "emoji": "",
            "label": "V1",
            "style": 2,
            "type": 2
        },
        {
            "customId": "MJ::JOB::variation::2::26d56b92-4ed6-45e2-8561-563797923135",
            "emoji": "",
            "label": "V2",
            "style": 2,
            "type": 2
        },
        {
            "customId": "MJ::JOB::variation::3::26d56b92-4ed6-45e2-8561-563797923135",
            "emoji": "",
            "label": "V3",
            "style": 2,
            "type": 2
        },
        {
            "customId": "MJ::JOB::variation::4::26d56b92-4ed6-45e2-8561-563797923135",
            "emoji": "",
            "label": "V4",
            "style": 2,
            "type": 2
        }
    ]
}

第三步: 点击按钮,执行动作

查询接口返回的 buttons 属性为可点击按钮,将对应的按钮 customId,传入接口 /mj/submit/action

{
  "customId": "MJ::JOB::upsample::2::3dbbd469-36af-4a0f-8f02-df6c579e7011",
  "taskId": "14001934816969359"
}

第四步 根据任务ID获取任务结果

直到进度结束。可继续再次操作、获取

接口详细介绍

类型1:提交Imagine任务

接口地址: /mj/submit/imagine

请求方式: POST

请求数据类型: application/json

响应数据类型: /

请求示例:

{
  "base64Array": [],
  "prompt": "Cat"
}

请求参数说明:

参数名称参数说明请求类型是否必须数据类型schema
imagineDTOimagineDTObodytrueImagine提交参数Imagine提交参数
base64Array垫图base64数组falsearraystring
prompt提示词truestring

响应状态说明:

状态码说明schema
200OK提交结果
401Unauthorized
403Forbidden
404Not Found

响应参数说明:

参数名称参数说明类型schema
code状态码: 1(提交成功), 22(排队中), other(错误)integer(int32)integer(int32)
description描述string
properties扩展字段object
result任务IDstring

响应示例:

{
    "code": 1,
    "description": "提交成功",
    "properties": {},
    "result": 1320098173412546
}

提交Blend任务

接口地址: /mj/submit/blend

请求方式: POST

请求数据类型: application/json

响应数据类型: /

请求示例:

{
  "base64Array": [
    "data:image/png;base64,xxx1",
    "data:image/png;base64,xxx2"
  ],
  "dimensions": "SQUARE"
}

请求参数说明:

参数名称参数说明请求类型是否必须数据类型schema
blendDTOblendDTObodytrueBlend提交参数Blend提交参数
base64Array图片base64数组truearraystring
dimensions比例: PORTRAIT(2:3); SQUARE(1:1); LANDSCAPE(3:2)falsestring

响应示例:

{
    "code": 1,
    "description": "提交成功",
    "properties": {},
    "result": 1320098173412546
}

提交图生文任务

接口地址: /mj/submit/describe

请求方式: POST

请求数据类型: application/json

响应数据类型: /

请求示例:

{
  "base64": "data:image/png;base64,xxx"
}

请求参数说明:

参数名称参数说明请求类型是否必须数据类型schema
describeDTOdescribeDTObodytrueDescribe提交参数Describe提交参数
base64图片base64truestring

响应示例:

{
    "code": 1,
    "description": "提交成功",
    "properties": {},
    "result": 1320098173412546
}

提交Shorten任务

接口地址: /mj/submit/shorten

请求方式: POST

请求数据类型: application/json

响应数据类型: /

请求示例:

{
  "prompt": "Cat"
}

请求参数说明:

参数名称参数说明请求类型是否必须数据类型schema
shortenDTOshortenDTObodytrueShorten提交参数Shorten提交参数
prompt提示词truestring

响应示例:

{
    "code": 1,
    "description": "提交成功",
    "properties": {},
    "result": 1320098173412546
}

类型2:执行动作

接口地址: /mj/submit/action

请求方式: POST

请求数据类型: application/json

响应数据类型: /

请求示例:

{
  "customId": "MJ::JOB::upsample::2::3dbbd469-36af-4a0f-8f02-df6c579e7011",
  "taskId": "14001934816969359"
}

请求参数说明:

参数名称参数说明请求类型是否必须数据类型schema
actionDTOactionDTObodytrue执行动作参数执行动作参数
customId动作标识truestring
taskId任务IDtruestring

响应示例:

{
    "code": 1,
    "description": "提交成功",
    "properties": {},
    "result": 1320098173412546
}

提交Modal

接口地址: /mj/submit/modal

请求方式: POST

请求数据类型: application/json

响应数据类型: /

请求示例:

{
  "maskBase64": "",
  "prompt": "",
  "taskId": "14001934816969359"
}

请求参数说明:

参数名称参数说明请求类型是否必须数据类型schema
modalDTOmodalDTObodytrueModal提交参数Modal提交参数
maskBase64局部重绘的蒙版base64falsestring
prompt提示词falsestring
taskId任务IDtruestring

响应示例:

{
    "code": 1,
    "description": "提交成功",
    "properties": {},
    "result": 1320098173412546
}

指定ID获取任务

接口地址: /mj/task/{id}/fetch

请求方式: GET

请求数据类型: application/x-www-form-urlencoded

响应数据类型: /

请求示例:

curl --request GET \
  --url {{BASE_URL}}/fast/mj/task/1320098173412546/fetch \
  --header 'Authorization: Bearer sk-替换为你的key' \
  -H "Content-Type: application/json"

请求参数说明:

参数名称参数说明请求类型是否必须数据类型schema
id任务IDpathtruestring

响应参数说明:

参数名称参数说明类型schema
action任务类型, 值: IMAGINE, UPSCALE, VARIATION, ZOOM, PAN, DESCRIBE, BLEND, SHORTENstring
buttons可执行按钮,再操作的可选按钮array
customId动作标识string
emoji图标string
label文本string
style样式: 2(Primary)、3(Green)integer(int32)
type类型,系统内部使用integer(int32)
description任务描述string
failReason失败原因string
finishTime结束时间integer(int64)integer(int64)
idIDstring
imageUrl图片urlstring
progress任务进度string
prompt提示词string
promptEn提示词-英文string
properties扩展字段object
startTime开始执行时间integer(int64)integer(int64)
state自定义参数string
status任务状态, 可用值: NOT_START, SUBMITTED, MODAL, IN_PROGRESS, FAILURE, SUCCESSstring
submitTime提交时间integer(int64)integer(int64)

响应示例:

{
    "action": "",
    "buttons": [
        {
            "customId": "",
            "emoji": "",
            "label": "",
            "style": 0,
            "type": 0
        }
    ],
    "description": "",
    "failReason": "",
    "finishTime": 0,
    "id": "",
    "imageUrl": "",
    "progress": "",
    "prompt": "",
    "promptEn": "",
    "properties": {},
    "startTime": 0,
    "state": "",
    "status": "",
    "submitTime": 0
}