Midjourney로 이미지 설명하기
CometAPI POST /mj/submit/describe를 사용해 업로드한 이미지에서 초기 Midjourney 프롬프트를 추출하여 빠르게 리믹스하고 반복 작업할 수 있습니다.
curl https://api.cometapi.com/mj/submit/describe \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"botType": "MID_JOURNEY",
"base64": "data:image/jpeg;base64,<base64-encoded-jpeg>"
}'import base64
import os
import requests
with open("cat.jpg", "rb") as f:
image_b64 = base64.b64encode(f.read()).decode()
response = requests.post(
"https://api.cometapi.com/mj/submit/describe",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"botType": "MID_JOURNEY",
"base64": "data:image/jpeg;base64," + image_b64,
},
)
task = response.json()
print(task["code"], task.get("result")) # poll the task; extracted prompts arrive in promptEn
import { readFile } from "node:fs/promises";
const imageB64 = (await readFile("cat.jpg")).toString("base64");
const response = await fetch("https://api.cometapi.com/mj/submit/describe", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
botType: "MID_JOURNEY",
base64: `data:image/jpeg;base64,${imageB64}`,
}),
});
const task = await response.json();
console.log(task.code, task.result); // poll the task; extracted prompts arrive in promptEn
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/mj/submit/describe",
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([
'base64' => 'data:image/png;base64,xxx'
]),
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/describe"
payload := strings.NewReader("{\n \"base64\": \"data:image/png;base64,xxx\"\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/describe")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"base64\": \"data:image/png;base64,xxx\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/mj/submit/describe")
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 \"base64\": \"data:image/png;base64,xxx\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"description": "<string>",
"properties": {},
"result": 123
}이 경로가 유용한 경우
- 이미지를 리믹스할 수 있는 프롬프트 후보로 변환할 때
- 새로운 imagine 작업을 시작하기 전에 시각적 방향성을 추출할 때
- 첫 프롬프트를 처음부터 작성하고 싶지 않을 때 더 빠른 작성 루프를 구축할 때
작업 흐름
이미지 제출
describe 작업 폴링
생성된 프롬프트 재사용
인증
Bearer token authentication. Use your CometAPI key.
본문
Base64-encoded image to describe. Use a data URI such as data:image/png;base64,xxx. Provide either base64 or link.
URL of the image to describe. Provide either link or base64.
Bot type to use. MID_JOURNEY for Midjourney (default), NIJI_JOURNEY for Niji.
NIJI_JOURNEY, MID_JOURNEY Custom state string. Returned as-is in the task result and webhook callback for your own tracking.
응답
Success
Submission status code. 1 = submitted successfully (result carries the task id). 21 = the action opened a confirmation modal; continue with /mj/submit/modal using the returned task id. 4 = parameter error; description explains the cause.
curl https://api.cometapi.com/mj/submit/describe \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"botType": "MID_JOURNEY",
"base64": "data:image/jpeg;base64,<base64-encoded-jpeg>"
}'import base64
import os
import requests
with open("cat.jpg", "rb") as f:
image_b64 = base64.b64encode(f.read()).decode()
response = requests.post(
"https://api.cometapi.com/mj/submit/describe",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"botType": "MID_JOURNEY",
"base64": "data:image/jpeg;base64," + image_b64,
},
)
task = response.json()
print(task["code"], task.get("result")) # poll the task; extracted prompts arrive in promptEn
import { readFile } from "node:fs/promises";
const imageB64 = (await readFile("cat.jpg")).toString("base64");
const response = await fetch("https://api.cometapi.com/mj/submit/describe", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
botType: "MID_JOURNEY",
base64: `data:image/jpeg;base64,${imageB64}`,
}),
});
const task = await response.json();
console.log(task.code, task.result); // poll the task; extracted prompts arrive in promptEn
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/mj/submit/describe",
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([
'base64' => 'data:image/png;base64,xxx'
]),
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/describe"
payload := strings.NewReader("{\n \"base64\": \"data:image/png;base64,xxx\"\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/describe")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"base64\": \"data:image/png;base64,xxx\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/mj/submit/describe")
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 \"base64\": \"data:image/png;base64,xxx\"\n}"
response = http.request(request)
puts response.read_body{
"code": 123,
"description": "<string>",
"properties": {},
"result": 123
}