跳转到主要内容
POST
/
mj
/
submit
/
imagine
Imagine(文生图)
curl --request POST \
  --url https://openp.ai/mj/submit/imagine
import requests

url = "https://openp.ai/mj/submit/imagine"

response = requests.post(url)

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

fetch('https://openp.ai/mj/submit/imagine', 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/submit/imagine",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);

$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/submit/imagine"

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

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

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

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://openp.ai/mj/submit/imagine")
.asString();
require 'uri'
require 'net/http'

url = URI("https://openp.ai/mj/submit/imagine")

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

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

response = http.request(request)
puts response.read_body
提交一个 Midjourney 文生图任务(等价于 Discord 的 /imagine)。

请求

curl https://openp.ai/mj/submit/imagine \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic cyberpunk city at night, neon lights, --ar 16:9 --v 6",
    "notifyHook": "https://your-server.com/mj-callback"
  }'

参数

字段类型必填说明
promptstring生成提示词,可包含 --ar--v--style 等参数
base64Arrayarray参考图 base64 数组(/imagine 附带垫图)
notifyHookstring回调 URL,任务完成时 OpenPAI 会 POST 任务结果
statestring自定义透传字段,会原样回传到回调
botTypestringMID_JOURNEY(默认)或 NIJI_JOURNEY

响应

{
  "code": 1,
  "description": "Submitted",
  "result": "1737200000000000",
  "properties": {}
}
result 即任务 ID,后续用它查询进度或提交 U/V 操作。
code含义
1提交成功
21已存在相同任务(将复用)
22任务进入队列等待
-1提交失败,见 description

查询任务

详见 Fetch

后续操作(U/V/Reroll)

详见 Change

计费

任务次数 + 操作类型 一笔固定扣费,与上游 Midjourney 订阅价格挂钩。 任务失败(无回调或上游返回错误)不扣费。