🔥 Midjourney API

TT API's Midjourney API is the most stable and cost-effective Midjourney API

Mode

The Midjourney service of TT API supports three modes, fast, relax and turbo.

  • Fast mode response time is within 90 seconds
  • Relax mode response generally within 10 minutes, depending on the official response
  • Turbo mode response time is within 60 seconds

Queue Jobs

The max job in progressing is 10, get more job in progress please contact us

Generate[ /imagine ]

POST {Domain}/midjourney/v1/imagine

💡

'Imagine action' with Midjourney 6.0 will be 1.5 times quota than the normal consumption.
--cref operation must be used with --v 6.0 model
The domain of hold account mode is different from the PPU mode

The imagine endpoint generates up to 4 images from a text prompt. And you can checkout the domain here
Same with the /imagine command in the midjourney

Headers

NameTypeDescription
TT-API-KEY*StringYour API Key in TT API used for request authorization

Request Body

NameTypeRequiredDescription
promptStringtruePrompt use to generate image. exp: a cat --ar 1:1
hookUrlStringfalseSend a request to the address for task completion or failed notification. If not set you need to request fetch endpoint to get result
modeStringfalseThe task mode for generating images, including fast, relax and turbo. If not filled in, the fast mode will be used by default.
timeoutIntfalseQueue timeout, unit: seconds. limits 300 - 1200.
the default timeout is 300 seconds for fast and turbo mode
And default timeout is 600 seconds for relax mode
getUImagesBooleanfalseWhether to obtain four small pictures. The optional values are true and false. Default is false. Note: This operation does not actually means U operation on the generated task.

Example Request

import requests
 
endpoint = "https://api.ttapi.io/midjourney/v1/imagine"
 
headers = {
"TT-API-KEY": your_key
}
 
data = {
    "prompt": "a cute cat",
    "model": "fast",
    "hookUrl": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "status": "SUCCESS",
    "message": "",
    "data": {
        "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4"
     }
}

Action[ U1-U4 V1-V4...]

POST {Domain}/midjourney/v1/action


This endpoint integrates all button operations of midjourney, and uses the jobId returned in the previous step to determine which task to operate. For details on supported enums. And you can checkout the domain here

Headers

NameTypeDescription
TT-API-KEY*StringYour API Key in TT API used for request authorization

Request Body

NameTypeRequiredDescription
jobIdStringtrueThe jobId in prev request
actionStringtrueAction you need
Eg: upsample1 means U1
      variation1 means V1
For more please refer to
hookUrlStringfalseSend a request to the address for task completion or failed notification. If not set you need to request fetch endpoint to get response
timeoutIntfalseRequest timeout, unit: seconds. If not filled in, the default timeout is 300 seconds
getUImagesBooleanfalseWhether to obtain four small pictures. The optional values are true and false. Default is false. Note: This operation does not actually means U operation on the generated task.

Example Request

import requests
 
endpoint = "https://api.ttapi.io/midjourney/v1/action"
 
headers = {
"TT-API-KEY": your_key
}
 
data = {
    "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4",
    "action": "upsample1",
    "hookUrl": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "status": "SUCCESS",
    "message": "",
    "data": {
        "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4"
    }
}

Seeds[ --seed ]

POST {Domain}/midjourney/v1/seed


Get the seeds form midjourney image, refer to the midjourney's docs (opens in a new tab) for usage. And you can checkout the domain here

Headers

NameTypeDescription
TT-API-KEY*StringYour API Key in TT API used for request authorization

Request Body

NameTypeRequiredDescription
jobIdStringtrueThe jobId in prev request
hookUrlStringfalseSend a request to the address for task completion or failed notification. If not set you need to request fetch endpoint to get response
timeoutIntfalseRequest timeout, unit: seconds. If not filled in, the default timeout is 300 seconds

Example Request

import requests
 
endpoint = "https://api.ttapi.io/midjourney/v1/seed"
 
headers = {
    "TT-API-KEY": your_key
}
 
    data = {
    "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4",
    "hookUrl": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "status": "SUCCESS",
    "message": "",
    "data": {
    "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4"
}
}

Blend[ /blend ]

POST {Domain}/midjourney/v1/blend


Upload 2-5 images and combine them into a new image based on the concept and aesthetic of each image. And you can checkout the domain here

Headers

NameTypeDescription
TT-API-KEY*StringYour API Key in TT API used for request authorization

Request Body

NameTypeRequiredDescription
imgBase64ArrayArraytrueBase64 array of images that will be used to generate mixed images
Array length is 2-5
Eg: [
"data:image/png;base64,xxx1",
"data:image/png;base64,xxx2"]
dimensionsStringfalseScale of generated image, including PORTRAIT, SQUARE, LANDSCAPE. If not filled in, SQUARE is used by default.
PORTRAIT corresponds to the ratio 2:3
SQUARE corresponding ratio 1:1
LANDSCAPE corresponds to a ratio of 3:2
modeStringfalseThe task mode for generating images, including fast, relax and turbo. If not filled in, the fast mode will be used by default.
hookUrlStringfalseSend a request to the address for task completion or failed notification. If not set you need to request fetch endpoint to get response
timeoutIntfalseRequest timeout, unit: seconds. If not filled in, the default timeout is 300 seconds

Example Request

import requests
 
endpoint = "https://api.ttapi.io/midjourney/v1/blend"
 
headers = {
    "TT-API-KEY": your_key
}
 
data = {
    "imgBase64Array":  ["data:image/png;base64,xxx1","data:image/png;base64,xxx2"],
    "dimensions": "SQUARE",
    "mode": "fast",
    "hookUrl": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "status": "SUCCESS",
    "message": "",
    "data": {
    "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4"
}

Describe[ /describe ]

POST {Domain}/midjourney/v1/describe


Upload an image and generate four prompts based on the image. And you can checkout the domain here

Headers

NameTypeDescription
TT-API-KEY*StringYour API Key in TT API used for request authorization

Request Body

NameTypeRequiredDescription
base64Stringtruebase64 encoding of image
Eg: data:image/png;base64,xxx1
modeStringfalseThe task mode for generating images, including fast, relax and turbo. If not filled in, the fast mode will be used by default.
hookUrlStringfalseSend a request to the address for task completion or failed notification. If not set you need to request fetch endpoint to get response
timeoutIntfalseRequest timeout, unit: seconds. If not filled in, the default timeout is 300 seconds

Example Request

import requests
endpoint = "https://api.ttapi.io/midjourney/v1/blend"
 
headers = {
    "TT-API-KEY": your_key
}
data = {
    "base64":  data:image/png;base64,xxx1,
    "mode": "fast",
    "hookUrl": ""
}
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "status": "SUCCESS",
    "message": "",
    "data": {
    "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4"
}

Inpaint[ Vary(region) ]

POST {Domain}/midjourney/v1/inpaint


Partial modifies of the image. And you can checkout the domain here

Headers

NameTypeDescription
TT-API-KEY*StringYour API Key in TT API used for request authorization

Request Body

NameTypeRequiredDescription
jobIdStringtrueThe jobId in prev request
maskStringtrueThe base64 content is a black and white film of the same size as the original image. The white part is the circled part of the redrawn image, and the rest is black. and not contains 'data:image/png;base64'
promptStringfalseDrawing prompt for selected areas
hookUrlStringfalseSend a request to the address for task completion or failed notification. If not set you need to request fetch endpoint to get response
timeoutIntfalseRequest timeout, unit: seconds. If not filled in, the default timeout is 300 seconds

Example Request

import requests
endpoint = "https://api.ttapi.io/midjourney/v1/inpaint"
headers = {
  "TT-API-KEY": your_key
}
data = {
  "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4",
  "prompt": "white background",
  "mask": "UklGRrw0AABXRUJQVlA4WAoAAAAgAAAA..."
  "hookUrl": ""
}
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "status": "SUCCESS",
    "message": "",
    "data": {
        "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4"
    }
}

Fetch Job

GET/POST {Domain}/midjourney/v1/fetch


to fetch the job result, Be careful not to request this interface with high concurrency to avoid being mistaken for an attack..
And you can checkout the domain here

Headers

NameTypeDescription
TT-API-KEY*StringYour API Key in TT API used for request authorization

Request Body / Query params

NameTypeRequiredDescription
jobIdStringtrueThe jobId in prev request

Example Request

import requests
endpoint = "https://api.ttapi.io/midjourney/v1/fetch"
headers = {
    "TT-API-KEY": your_key
}
data = {
    "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4",
}
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

The result returned by the fetch endpoint has the same data structure as the result returned by hookUrl, as follows

Prompt Checker

POST https://api.ttapi.io/midjourney/v1/promptCheck


Check whether the prompt is compliant. This endpoint is a free endpoint.

Headers

NameTypeDescription
TT-API-KEY*StringYour API Key in TT API used for request authorization

Request Body

NameTypeRequiredDescription
promptStringtruesexy girl

Example Request

import requests
endpoint = "https://api.ttapi.io/midjourney/v1/promptCheck"
headers = {
    "TT-API-KEY": your_key
}
data = {
    "prompt": "sexy girl",
}
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "status": "SUCCESS", // SUCCESS or FAILED
    "message": "success",
    "data": "Prompt verification successful."
}

Async callback & fetch json

{
    "status": "SUCCESS",
    "jobId": "f5850038-90a3-8a97-0476-107ea4b8dac4",
    "message": "success",
    "data": {
        "actions": "imagine",
        "jobId": "f5850038-90a3-8a97-0476-107ea4b8dac4",
        "progress": "100",
        "prompt": "Soccer star Max Kruse and Jan-Peter Jachtmann victims of €528,695 poker scam, German soccer star Max Kruse and WSOP Main Event finalist Jan-Peter Jachtmann are among the players who have been swindled out of €528,695., poker, realistic --ar 1280:720",
        "discordImage": "https://cdn.discordapp.com/attachments/1107938555931656214/1176340921227423844/voyagel_Soccer_star_Max_Kruse_and_Jan-Peter_Jachtmann_victims_o_c513a87b-eed3-4a3b-ab97-6be4dbc3ea99.png?ex=656e83da&is=655c0eda&hm=6e06a1dec3c6c1be209799884681969878eabb81ce81f8db22d54480379fcd9b&",
        "cdnImage": "http://127.0.0.1/8080/pics/452020f2-6793-4525-a1b5-472cac439610.png",
        "width": 1632,
        "height": 2912,
        "hookUrl": "",
        "components": [
            "upsample1",
            "upsample2",
            "upsample3",
            "upsample4",
            "variation1",
            "variation2",
            "variation3",
            "variation4"
        ],
        "seed":"",
        "images":[
            "https://cdnb.ttapi.io/2024-04-02/27024084bcd54b1c38d085d11d8dc841037a2262ebeda29b3f67b741441f6736.png",
            "https://cdnb.ttapi.io/2024-04-02/e15e39f6eb39191fdf3f176f8c979b6e57254114a8bfea826e30f23850d0d485.png",
            "https://cdnb.ttapi.io/2024-04-02/4b7910497a0d79d0155cd8b33eea313425cf2b809efef4b6ba3960aa1c2bd484.png",
            "https://cdnb.ttapi.io/2024-04-02/98b162a1da713eef23c3cfd5f166aee8e4ee09f8cf1f7bbc24bf72990eb80adf.png"
        ]
    }
}

Return body description

Starting from December 1, 2023, the cdn image link returned by discord will expire after in 24 - 72 hours.

namevalue
statusPENDING_QUEUE
ON_QUEUE
SUCCESS
FAILED
progessCompleteness : 0-100
componentsallow the 'action params' in next action endpoint
discordImageDiscord cdn image url
imagesCDN address of TTAPI, four small pictures generated by the imagine command.TTAPI will be kept for at least one month without expiration.

Action Used In action endpoint

For specific usage of related operations, you can read Midjourney’s official doc (opens in a new tab) in detail.

actiondescription
upsample1Button UI - U4
Same as upsample2, upsample3, upsample4
variation1Button VI - V4
Same as variation2, variation3, variation4
high_variationButton Vary (Strong)
Make drastic changes to your image
low_variationButton Vary (Subtle)
Make small changes to the image
upscale2Button **Upscale(2x) **
Image magnification 2 times
upscale4Button **Upscale(4x) **
Image magnification 4 times
zoom_out_2Button Zoom Out 2x
The Zoom Out option expands the canvas of the enlarged image without changing the original image, filling the new space based on the prompt and the initial image.
zoom_out_1_5Button Zoom Out 1.5x
The Zoom Out option expands the canvas of the enlarged image without changing the original image, filling the new space based on the prompt and the initial image.
pan_leftButton ⬅️➡️⬆️⬇️
Same as pan_right, pan_up, pan_down
upscale_creativeButton Upscale(Creative)
Only exists in v6 mode
upscale_subtleButton Upscale(Subtle)
Only exists in v6 mode
high_variationButton Vary (Strong)
Make drastic changes to your image