Midjourney API
curl --request POST \
--url https://toapis.com/v1/midjourney/generations \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"image_urls": [
"<string>"
],
"task_id": "<string>",
"speed": "<string>",
"version": "<string>"
}
'import requests
url = "https://toapis.com/v1/midjourney/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"image_urls": ["<string>"],
"task_id": "<string>",
"speed": "<string>",
"version": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
image_urls: ['<string>'],
task_id: '<string>',
speed: '<string>',
version: '<string>'
})
};
fetch('https://toapis.com/v1/midjourney/generations', 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://toapis.com/v1/midjourney/generations",
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([
'model' => '<string>',
'prompt' => '<string>',
'image_urls' => [
'<string>'
],
'task_id' => '<string>',
'speed' => '<string>',
'version' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://toapis.com/v1/midjourney/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"task_id\": \"<string>\",\n \"speed\": \"<string>\",\n \"version\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://toapis.com/v1/midjourney/generations")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"task_id\": \"<string>\",\n \"speed\": \"<string>\",\n \"version\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://toapis.com/v1/midjourney/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"task_id\": \"<string>\",\n \"speed\": \"<string>\",\n \"version\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyMidjourney
Midjourney API
通过 APIMart 渠道调用 Midjourney 的统一异步 API
POST
/
v1
/
midjourney
/
generations
Midjourney API
curl --request POST \
--url https://toapis.com/v1/midjourney/generations \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"image_urls": [
"<string>"
],
"task_id": "<string>",
"speed": "<string>",
"version": "<string>"
}
'import requests
url = "https://toapis.com/v1/midjourney/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"image_urls": ["<string>"],
"task_id": "<string>",
"speed": "<string>",
"version": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
image_urls: ['<string>'],
task_id: '<string>',
speed: '<string>',
version: '<string>'
})
};
fetch('https://toapis.com/v1/midjourney/generations', 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://toapis.com/v1/midjourney/generations",
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([
'model' => '<string>',
'prompt' => '<string>',
'image_urls' => [
'<string>'
],
'task_id' => '<string>',
'speed' => '<string>',
'version' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://toapis.com/v1/midjourney/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"task_id\": \"<string>\",\n \"speed\": \"<string>\",\n \"version\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://toapis.com/v1/midjourney/generations")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"task_id\": \"<string>\",\n \"speed\": \"<string>\",\n \"version\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://toapis.com/v1/midjourney/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"task_id\": \"<string>\",\n \"speed\": \"<string>\",\n \"version\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyMidjourney 使用本系统的统一异步任务 ID. 请求需要
Authorization: Bearer YOUR_API_KEY. 中国大陆用户请将 Base URL 替换为 https://toapis.cn.imagine, blend, describe, edits, upscale, variation, high-variation, low-variation, reroll, zoom, pan, inpaint, modal, video, remix-strong, remix-subtle.
所有提交接口返回任务 ID, 使用 查询接口 获取结果. 上游 APIMart 的 task ID 不需要由客户端传入或保存.
接口
| 操作 | 方法和路径 |
|---|---|
| 默认生成 | POST /v1/midjourney/generations |
| 指定操作 | POST /v1/midjourney/generations/{action} |
| 查询任务 | GET /v1/midjourney/{task_id} |
imagine.
通用请求字段
string
必填
固定为
midjourney.string
文本提示词.
imagine 和 edits 必填, modal 可选并默认继承父任务提示词.string
父任务 ID. 用于图片操作、视频和 Remix. 必须属于当前 API Key 对应用户.
string
默认值:"relax"
relax, fast 或 turbo.string
Midjourney 版本, 例如
v8.2, v8.1, v7, v6.1.提交示例
cURL
curl --request POST \
--url https://toapis.com/v1/midjourney/generations/imagine \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "midjourney",
"prompt": "a cinematic lighthouse above a stormy sea",
"speed": "fast",
"version": "v8.2"
}'
Response
{
"id": "tsk_img_xxx",
"object": "generation.task",
"model": "midjourney",
"status": "queued",
"progress": 0,
"created_at": 1710000000
}
APIMart 没有取消接口. 本系统不会虚构取消接口. 失败任务按照统一任务规则处理退款和 webhook.