跳转到主要内容
GET
/
mj
/
task
/
{id}
/
fetch
Fetch(查询任务)
curl --request GET \
  --url https://openp.ai/mj/task/{id}/fetch
import requests

url = "https://openp.ai/mj/task/{id}/fetch"

response = requests.get(url)

print(response.text)
const options = {method: 'GET'};

fetch('https://openp.ai/mj/task/{id}/fetch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://openp.ai/mj/task/{id}/fetch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://openp.ai/mj/task/{id}/fetch"

req, _ := http.NewRequest("GET", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://openp.ai/mj/task/{id}/fetch")
.asString();
require 'uri'
require 'net/http'

url = URI("https://openp.ai/mj/task/{id}/fetch")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
获取 Midjourney 任务的当前状态、进度与结果图链接。

请求

curl https://openp.ai/mj/task/1737200000000000/fetch \
  -H "Authorization: Bearer $OPENPAI_API_KEY"

响应

{
  "id": "1737200000000000",
  "action": "IMAGINE",
  "status": "SUCCESS",
  "progress": "100%",
  "prompt": "A futuristic cyberpunk city at night",
  "promptEn": "A futuristic cyberpunk city at night, neon lights, --ar 16:9 --v 6",
  "description": "Submit success",
  "submitTime": 1715750400000,
  "startTime": 1715750405000,
  "finishTime": 1715750460000,
  "imageUrl": "https://...",
  "failReason": null,
  "properties": {
    "finalPrompt": "A futuristic cyberpunk city...",
    "messageId": "...",
    "discordChannelId": "..."
  },
  "buttons": [
    {"customId": "MJ::JOB::upsample::1::...", "emoji": "", "label": "U1", "style": 2, "type": 2},
    {"customId": "MJ::JOB::variation::1::...", "emoji": "", "label": "V1", "style": 2, "type": 2}
  ]
}

status 取值

含义
NOT_START尚未开始
SUBMITTED已提交,等待上游
IN_PROGRESS生成中(看 progress 字段)
SUCCESS成功
FAILURE失败

buttons

Midjourney 任务完成后,Discord 上可点击的按钮(U1-U4、V1-V4、🔄)以 buttons 数组形式回传。 若需要执行某个按钮对应的操作,可用 change + customId

批量查询

curl -X POST https://openp.ai/mj/task/list-by-condition \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "ids": ["task1", "task2", "task3"] }'
返回任务对象数组,可减少轮询请求次数。

回调 vs 轮询

  • 回调(notifyHook):任务状态变更时 OpenPAI 主动 POST 到你的服务,生产推荐。
  • 轮询(fetch):简单,但有延迟,适合本地脚本。
回调请求示例(POST 到 notifyHook):
{
  "id": "1737200000000000",
  "action": "IMAGINE",
  "status": "SUCCESS",
  "imageUrl": "https://...",
  "state": "<提交时传入的 state 透传>"
}