Midjourney
创建一个 Midjourney modal 任务
使用 POST /mj/submit/modal 提交来自缩放或区域重绘的 Midjourney modal 输出,并在 CometAPI 中继续下一步图像编辑流程。
POST
/
mj
/
submit
/
modal
cURL
curl https://api.cometapi.com/mj/submit/modal \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"taskId": "<task_id>",
"customId": "MJ::Inpaint::1::<custom_id_hash>::SOLO",
"prompt": "a small red lantern on the boat",
"maskBase64": "data:image/png;base64,<your-mask-base64>"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/mj/submit/modal",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"taskId": "<task_id>",
"customId": "MJ::Inpaint::1::<custom_id_hash>::SOLO",
"prompt": "a small red lantern on the boat",
"maskBase64": "data:image/png;base64,<your-mask-base64>"
},
)
task = response.json()
print(task["code"], task.get("result")) # code 1 means submitted; result is the task idconst response = await fetch("https://api.cometapi.com/mj/submit/modal", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"taskId": "<task_id>",
"customId": "MJ::Inpaint::1::<custom_id_hash>::SOLO",
"prompt": "a small red lantern on the boat",
"maskBase64": "data:image/png;base64,<your-mask-base64>"
}),
});
const task = await response.json();
console.log(task.code, task.result); // code 1 means submitted; result is the task id<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/mj/submit/modal",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'taskId' => '<task_id>',
'customId' => 'MJ::Inpaint::1::<custom_id_hash>::SOLO'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/mj/submit/modal"
payload := strings.NewReader("{\n \"taskId\": \"<task_id>\",\n \"customId\": \"MJ::Inpaint::1::<custom_id_hash>::SOLO\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/mj/submit/modal")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"taskId\": \"<task_id>\",\n \"customId\": \"MJ::Inpaint::1::<custom_id_hash>::SOLO\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/mj/submit/modal")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"taskId\": \"<task_id>\",\n \"customId\": \"MJ::Inpaint::1::<custom_id_hash>::SOLO\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"description": "<string>",
"properties": {},
"result": 123
}概述
当某个 Action 任务返回status: "MODAL" 时,提交额外输入。这对于需要附加数据的操作是必需的,例如局部重绘蒙版或自定义缩放 Prompt。
何时使用
| 操作 | 需要提交的内容 |
|---|---|
| Vary (Region) / Inpaint | maskBase64(PNG 蒙版)+ prompt |
| Custom Zoom | prompt(例如:“your prompt —zoom 2”) |
完整的局部重绘流程示例,请参阅 Start with Midjourney API。
授权
Bearer token authentication. Use your CometAPI key.
请求体
application/json
Task id from the parent task whose modal action you are continuing.
The button customId that opened the modal, such as MJ::Inpaint::1::xxxx::SOLO from the Vary (Region) button. Required.
Base64-encoded mask image for partial inpainting. White areas are repainted; black areas are preserved.
Text prompt describing the desired change for the selected region.
⌘I
cURL
curl https://api.cometapi.com/mj/submit/modal \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"taskId": "<task_id>",
"customId": "MJ::Inpaint::1::<custom_id_hash>::SOLO",
"prompt": "a small red lantern on the boat",
"maskBase64": "data:image/png;base64,<your-mask-base64>"
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/mj/submit/modal",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"taskId": "<task_id>",
"customId": "MJ::Inpaint::1::<custom_id_hash>::SOLO",
"prompt": "a small red lantern on the boat",
"maskBase64": "data:image/png;base64,<your-mask-base64>"
},
)
task = response.json()
print(task["code"], task.get("result")) # code 1 means submitted; result is the task idconst response = await fetch("https://api.cometapi.com/mj/submit/modal", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"taskId": "<task_id>",
"customId": "MJ::Inpaint::1::<custom_id_hash>::SOLO",
"prompt": "a small red lantern on the boat",
"maskBase64": "data:image/png;base64,<your-mask-base64>"
}),
});
const task = await response.json();
console.log(task.code, task.result); // code 1 means submitted; result is the task id<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/mj/submit/modal",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'taskId' => '<task_id>',
'customId' => 'MJ::Inpaint::1::<custom_id_hash>::SOLO'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/mj/submit/modal"
payload := strings.NewReader("{\n \"taskId\": \"<task_id>\",\n \"customId\": \"MJ::Inpaint::1::<custom_id_hash>::SOLO\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/mj/submit/modal")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"taskId\": \"<task_id>\",\n \"customId\": \"MJ::Inpaint::1::<custom_id_hash>::SOLO\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/mj/submit/modal")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"taskId\": \"<task_id>\",\n \"customId\": \"MJ::Inpaint::1::<custom_id_hash>::SOLO\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"description": "<string>",
"properties": {},
"result": 123
}