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
Access Midjourney through the unified asynchronous API backed by APIMart
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 uses ToAPIs task IDs. Requests require
Authorization: Bearer YOUR_API_KEY. If you are in mainland China, use https://toapis.cn as the Base URL instead.imagine, blend, describe, edits, upscale, variation, high-variation, low-variation, reroll, zoom, pan, inpaint, modal, video, remix-strong, remix-subtle.
Every submission returns a task ID. Use the query endpoint to retrieve results. You do not need to provide or retain the upstream APIMart task ID.
Endpoints
| Operation | Method and path |
|---|---|
| Default generation | POST /v1/midjourney/generations |
| Specific action | POST /v1/midjourney/generations/{action} |
| Query a task | GET /v1/midjourney/{task_id} |
imagine.
Common request fields
string
required
Must be
midjourney.string
Text prompt. Required for
imagine and edits; optional for modal, which inherits the parent prompt by default.string[]
Publicly accessible image URLs. Use the image upload endpoint first; do not submit base64 directly. Each image must be no larger than 12 MiB.
string
Parent task ID for image actions, video, and Remix. The task must belong to the user associated with the current API key.
string
default:"relax"
relax, fast, or turbo.string
Midjourney version, such as
v8.2, v8.1, v7, or v6.1.Submit a task
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 does not provide a cancellation endpoint. ToAPIs does not expose a fabricated cancellation endpoint. Failed tasks follow the standard refund and webhook rules.