Midjourney Blend多图融合

注意:本 API 属于生成式人工智能 API,出于安全考虑,请务必在使用时不要输入带有国家和企业机密的相关信息,同时本 API 也会严格遵循中华人民共和国《生成式人工智能服务管理办法》严格把控和过滤相关敏感、不道德、侵权等信息。

Midjourney 是一个强大的图像生成服务,可以通过自然语言描述生成对应的精美图像。本 API 对接了 Midjourney 官方,提供了 Midjourney 的调用能力,并支持图像的预览生成和连续修改操作。
支持中文,imagine,U图,V图,图生图,图生文,Seed种子,人脸融合等。
原版 中文

一.您的KEY

点击前往获取KEY |【MJ绘图】点击KEY按钮获取

二.创建任务

请求地址:https://mjapi.ai-gs.cn/v1/blend

请求方式:POST

URL:

参数
token string 必填参数 点击前往获取KEY

请求头:

参数
Content-Type string 必填参数 application/json
Accept string 必填参数
application/json

请求体:

参数
image_url1 string 必须
第 1 幅图像 URL。该链接需要是可以直接访问的图片,不能是网页内嵌图片。
image_url2 string 必须
第 2 幅图像 URL。该链接需要是可以直接访问的图片,不能是网页内嵌图片。
image_url3 string 非必需
第 3 幅图像 URL。该链接需要是可以直接访问的图片,不能是网页内嵌图片。
image_url4 string 非必需
第 4 幅图像 URL。该链接需要是可以直接访问的图片,不能是网页内嵌图片。
image_url5 string 非必需
第 5 幅图像 URL。该链接需要是可以直接访问的图片,不能是网页内嵌图片。
prompt string 非必需
图像描述。在第一次生图时,需要指定该字段,代表待生成图像的描述。强烈建议用英文,中文可能导致生成内容不匹配
timeout number 非必需 超时秒数。用于指定该 API 返回数据的最长等待时间。该值默认为 480,即 480 秒
callback_url string 必须
Webhook 回调 URL。默认情况下,本 API 会进行长等待一直到图片生成完毕才返回响应。图片生成完毕之后,生成结果将会以 POST 形式发送到此 Webhook URL。

创建任务请求体例子:

  • generate

    {
        "image_url1": "https:\/\/xxxxx.com\/1.png",
        "image_url2": "https:\/\/xxxxx.com\/2.png",
        "image_url3": "https:\/\/xxxxx.com\/3.png",
        "prompt": "a chinese girl --ar 3:4",
        "timeout": 1000,
        "callback_url": "https:\/\/xxxxx.com\/callback_url"
    }
                                                    


三.接口返回

创建任务响应状态:

  • 200 成功

    200 获取到一个task_id
    { "task_id": "86b30ab4-d0d7-49b9-b65c-ac5e2d4f0127" }
    等Midjourney开始出图,callback_url会接收到完整内容,使用task_id作为识别。你也可以在callback_url自行定义唯一url参数来识别

  • 400 错误

    • no_token

      使用的 API 时未携带 token,无法通过校验。
      { "code": "no_token", "detail": "No token specified in url query." }

    • api_not_implemented

      使用的 API 在系统中未实现,无法通过校验。
      { "code": "api_not_implemented", "detail": "The API is not implemented." }


  • 401 错误

    invalid_token 请求 API 时传入的 token 无效,需要更换 token 或者重新申请。
    { "code": "invalid_token", "detail": "The token is invalid, please make sure your token is correct." }
  • 403 错误

    • used_up

      错误代码,API 套餐已经用完,需要充值 { "code": "used_up", "detail": "Your packaged has been used up, please buy more in system." }

    • forbidden

      生成图片操作被禁止,大部分会遇到如下 2 种情况,detail 字段如下: 1. The prompt has blocked words `xxx`:对输入 prompt 增加了违禁词检测,如果 prompt 包含违禁词,则会显示提示输入的 prompt 不合规。建议的解决办法是请更换 prompt 中的违禁词。 2. Sorry! Our Al moderators feel your prompt might be against our community standards:当上述prompt 违禁词检测没有问题时,Midjourney 还会有第二层 AI 判定输入的 prompt 是否有问题或者敏感,如果 AI 判定输入词有问题,则只会提示上述内容。注意:因为这里输入 Midjourney AI 判定,所以里面有些误判或者不可控因素在里面,建议的解决办法是对输入的 prompt 进行微调,大概率就能通过。 { "code": "forbidden", "detail": "Sorry! Our Al moderators feel your prompt might be against our community standards" }

    • unverified

      未完成实名认证,需要到系统里面完成实名认证才可使用 API。 { "code": "unverified", "detail": "You did not finish Real-name auth, please verify in the system" }
  • 404 错误

    no_api 请求的 API 不存在,请确保 API 路径正确。 { "code": "no_api", "detail": "API does not exist, please make sure url is correct." }
  • 500 unknown

    未知错误,需要联系系统管理员。 { "code": "unknown", "detail": "Unknown server error, please contact admin." }

四.任务回调内容

成功创建任务后,callback_url链接地址会收到通知,通知内容为json格式。

Midjourney是流式内容,所以同一个task_id会有多条通知,直到进度为100

请留意actions参数,例如U图可用的actions跟其它不同

参数
success boolean 状态:true为出图成功,false为出图失败
task_id string
任务ID
image_id string
图片ID
image_url string
缩略图链接
image_width string
缩略图宽度
image_width string
缩略图高度
raw_image_url string
完整图链接
raw_image_width number
完整图宽度
raw_image_width number
完整图高度
progress number
进度,midjourney从0-100,但进度为100,actions参数就会有内容
actions array
可操作行为。该图片后续可进行的操作行为。配合image_id进行后面行为。
code string
出图失败才有该参数,出错类型
detail string
出图失败才有该参数,出错详情
trace_id string
出图失败才有该参数,追踪ID

任务回调例子:

  • 任务 成功

    {
        "success": true,
        "task_id": "f563fcef-64ce-4372-ae88-74e5a38697f4",
        "image_url": "https://midjourney.cdn.ai-gs.cn/attachments/1124768570157564029/1183439422973284392/mceachernlakeesha_Place_several_pieces_of_paper_on_a_dark_yello_2f813f98-e016-4def-8d43-9be7e607a705.png?ex=658856d9&is=6575e1d9&hm=a895251076ddb352ec15e9e4b0f54c2b20c4d87b4ea1c1f5dace0c15b963419d&width=1024&height=1024",
        "image_width": 1024,
        "image_height": 1024,
        "image_id": "1183439422973284392",
        "raw_image_url": "https://midjourney.cdn.ai-gs.cn/attachments/1124768570157564029/1183439422973284392/mceachernlakeesha_Place_several_pieces_of_paper_on_a_dark_yello_2f813f98-e016-4def-8d43-9be7e607a705.png?ex=658856d9&is=6575e1d9&hm=a895251076ddb352ec15e9e4b0f54c2b20c4d87b4ea1c1f5dace0c15b963419d&",
        "raw_image_width": 2048,
        "raw_image_height": 2048,
        "progress": 100,
        "actions": ["upsample1", "upsample2", "upsample3", "upsample4", "reroll", "variation1", "variation2", "variation3", "variation4"]
    }
                                                    


  • 任务 失败

    {
        "success": false,
        "task_id": "0ad6b31c-0a1f-4a17-acea-922bde5fab1a",
        "code": "forbidden",
        "detail": "There is already an task processing this image, please try again later.",
        "trace_id": "d3e685e9-357d-4565-9bbb-6bb9c5ff5734"
    }