Skip to content

Midjourney Proxy ​

Midjourney Proxy 接口用于提交 MJ 生图任务,并通过任务查询接口轮询结果。当前支持文生图、变体、高清、重绘、扩图、局部重绘、Remix 和移除背景。

MJ 查询接口会返回生成结果。图片结果在 images[].image_url 中读取。

接口地址 ​

能力方法路径
文生图POST/mj/submit/imagine
变体 / 高清 / 重绘 / 扩图 / 局部重绘 / Remix / 移除背景POST/mj/submit/change
简写操作POST/mj/submit/simple-change
查询任务GET/mj/task/{id}/fetch

文生图 ​

http
POST /mj/submit/imagine

参数 ​

参数必填说明
prompt是图片提示词

示例 ​

bash
curl -X POST https://cubicspaces.cloud/mj/submit/imagine \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "prompt": "A simple red ceramic mug on a clean white studio background"
  }'

返回 ​

json
{
  "code": 1,
  "description": "submit_success",
  "result": "mj-task-id"
}

保存 result,后续用任务查询接口轮询状态。

查询任务 ​

http
GET /mj/task/{id}/fetch
bash
curl https://cubicspaces.cloud/mj/task/mj-task-id/fetch \
  -H "Authorization: Bearer YOUR_API_KEY"

返回示例 ​

json
{
  "extra": {
    "has_nsfw_contents": []
  },
  "task": {
    "task_id": "mj-task-id",
    "task_type": "MIDJOURNEY_TEXT_TO_IMAGE_FAST_MODE",
    "status": "TASK_STATUS_SUCCEED",
    "reason": "",
    "eta": 0,
    "progress_percent": 0
  },
  "images": [
    {
      "image_url": "https://example.com/generated-1.png",
      "image_url_ttl": "0",
      "image_type": "png",
      "nsfw_detection_result": null
    }
  ],
  "videos": [],
  "audios": []
}

任务状态 ​

状态说明
TASK_STATUS_QUEUED任务排队中
TASK_STATUS_PROCESSING任务处理中
TASK_STATUS_SUCCEED已完成,读取 images[].image_url
TASK_STATUS_FAILED失败,查看 task.reason

建议每 5 秒轮询一次,直到任务进入成功或失败状态。

变体 ​

变体会基于原任务里的某一张图继续生成相似但不同的新图。

http
POST /mj/submit/change
参数必填说明
taskId是原始任务 ID
action是固定为 VARIATION
index是原图序号,取值 1 到 4
prompt否Remix 提示词
bash
curl -X POST https://cubicspaces.cloud/mj/submit/change \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "taskId": "mj-task-id",
    "action": "VARIATION",
    "index": 1
  }'

高清 ​

高清会把原任务里的某一张图单独高清化。

http
POST /mj/submit/change
参数必填说明
taskId是原始任务 ID
action是固定为 UPSCALE
index是原图序号,取值 1 到 4
bash
curl -X POST https://cubicspaces.cloud/mj/submit/change \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "taskId": "mj-task-id",
    "action": "UPSCALE",
    "index": 1
  }'

重绘 ​

重绘会基于原任务重新生成一批图片。

http
POST /mj/submit/change
参数必填说明
taskId是原始任务 ID
action是固定为 REROLL
bash
curl -X POST https://cubicspaces.cloud/mj/submit/change \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "taskId": "mj-task-id",
    "action": "REROLL"
  }'

扩图 ​

扩图会基于原任务里的某一张图向画面外扩展。action 可以使用 ZOOM 或 OUTPAINT。

http
POST /mj/submit/change
参数必填说明
taskId是原始任务 ID
action是ZOOM 或 OUTPAINT
index是原图序号,取值 1 到 4
prompt是扩图区域提示词
scale是扩图比例,通常为 1.1 到 2.0
bash
curl -X POST https://cubicspaces.cloud/mj/submit/change \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "taskId": "mj-task-id",
    "action": "ZOOM",
    "index": 1,
    "prompt": "extend the beach and sunset sky",
    "scale": 1.2
  }'

局部重绘 ​

局部重绘会对指定遮罩区域重新生成内容。

http
POST /mj/submit/change
参数必填说明
taskId是原始任务 ID
action是固定为 INPAINT
index是原图序号,取值 1 到 4
prompt否重绘区域提示词
mask是遮罩对象,可使用 url 或多边形区域描述。不要直接传原始 base64 字符串。
bash
curl -X POST https://cubicspaces.cloud/mj/submit/change \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "taskId": "mj-task-id",
    "action": "INPAINT",
    "index": 1,
    "prompt": "replace the car with a bicycle",
    "mask": {
      "url": "https://example.com/mask.png"
    }
  }'

多边形遮罩示例:

json
{
  "taskId": "mj-task-id",
  "action": "INPAINT",
  "index": 1,
  "prompt": "replace the center area with a glowing blue canvas",
  "mask": {
    "areas": [
      {
        "points": [350, 350, 674, 350, 674, 674, 350, 674],
        "width": 1024,
        "height": 1024
      }
    ]
  }
}

Remix ​

Remix 会基于原任务里的某一张图,用新的提示词进行强调整或细微调整。

http
POST /mj/submit/change
参数必填说明
taskId是原始任务 ID
action是固定为 REMIX
index是原图序号,取值 1 到 4
prompt是新提示词
mode否Remix 模式,0 为强调整,1 为细微调整;默认 0
bash
curl -X POST https://cubicspaces.cloud/mj/submit/change \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "taskId": "mj-task-id",
    "action": "REMIX",
    "index": 1,
    "prompt": "make it cinematic, night lighting",
    "mode": 0
  }'

移除背景 ​

移除背景会对指定图片 URL 创建去背景任务,不需要传入原始 MJ 任务 ID。

http
POST /mj/submit/change
参数必填说明
action是固定为 REMOVE_BACKGROUND
url是需要去背景的图片 URL
bash
curl -X POST https://cubicspaces.cloud/mj/submit/change \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "action": "REMOVE_BACKGROUND",
    "url": "https://example.com/source.png"
  }'

简写操作 ​

也可以使用 /mj/submit/simple-change 传入简写指令:

bash
curl -X POST https://cubicspaces.cloud/mj/submit/simple-change \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "content": "mj-task-id U1"
  }'

常见简写:

写法等价操作
mj-task-id U1高清第 1 张
mj-task-id V1变体第 1 张
mj-task-id R重绘

注意事项 ​

  • index 使用 MJ 风格的 1 到 4。
  • 操作接口返回的新任务 ID 也需要通过 /mj/task/{id}/fetch 轮询。
  • 变体、高清、重绘、扩图、局部重绘和 Remix 必须基于同一账号可访问的原任务。
  • 当前支持 mj_imagine、mj_variation、mj_upscale、mj_reroll、mj_zoom、mj_outpaint、mj_inpaint、mj_remix 和 mj_remove_background。