Docs
Midjourney API V1

Midjourney API V1

Documentation of Version 1 of all available Midjourney API endpoints, and their headers, body, sample requests and responses.
We are adding more awesome features on our V2 version! Please check it out and migrate to V2 before October 1st, 2023.




Midjourney API Endpoints

Imagine

POST

https://api.midjourneyapi.xyz/mj/imagine

The imagine endpoint generates up to 4 images from a text prompt.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
promptstring✔️the prompt for Midjourney AI that text description of the image you want to, multiple image parameters can added to the end of description.

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

To learn more about writing prompts and using parameters, please refer to Midjourney's documentation.


Example Request

curl -X POST -H "X-API-KEY: YOUR_API_KEY" -H "Content-Type: application/json" -d '{
    "prompt": "a running cat in jungle"
}' "https://api.midjourneyapi.xyz/mj/imagine"

Example Response

{
    "task_id": "d6fda928-9420-436a-93e4-9d316a269fda",
    "success": true,
    "message": ""
}


Upscale

POST

https://api.midjourneyapi.xyz/mj/upscale

The upscale endpoint upscales one of the four generated images to a higher resolution.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
origin_task_idstring✔️Returned by the task_id parameter in the response upon an image generation request
indexstring✔️The index of the image to upscale; can be 1, 2, 3, 4

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Using upscale function just like when you click U1 U2 U3 U4 buttons in Discord when using the Midjourney Bot

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/upscale"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "origin_task_id": "d6fda928-9420-436a-93e4-9d316a269fda",
    "index": "2"
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "task_id": "d6fda928-9420-436a-93e4-9d316a269fda",
    "success": true,
    "message": ""
}


Variation

POST

https://api.midjourneyapi.xyz/mj/variation

The variation endpoint generates slight variations of the indexed image.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
origin_task_idstring✔️Returned by the task_id parameter in the response upon an image generation request
indexstring✔️The index of the image to upscale; can be 1, 2, 3, 4

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Using variation function just like when you click V1 V2 V3 V4 buttons in Discord using the Midjourney Bot

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/variation"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "origin_task_id": "d6fda928-9420-436a-93e4-9d316a269fda",
    "index": "2"
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "task_id": "d1ac25ab-294c-4a91-ae92-f51023fddf34",
    "success": true,
    "message": ""
}


Describe

POST

https://api.midjourneyapi.xyz/mj/describe

The describe endpoint generates four possible prompts based on the uploaded image.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
filefile✔️Select files

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/describe"
 
file_path = r"/path/to/your/file.jpg"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
files = {
  'file': open(file_path, 'rb')
}
 
response = requests.post(endpoint, headers=headers, files=files)
 
print(response.status_code)
print(response.json())

Example Response

{
    "task_id": "8a8dff39-b516-4484-8ef4-830e068f2763",
    "success": true,
    "message": ""
}


Blend

POST

https://api.midjourneyapi.xyz/mj/blend

The blend endpoint merges multiple images into a novel new image.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
imagesfile✔️Select images to blend

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/blend"
 
file_path = [
    r"E:\BT\MJ\230714\81N8HnjtMhL._AC_UF894,1000_QL80_.jpg",
    r"E:\BT\MJ\230714\0455992ec21b38388cf9e0f285696707.jpg",
    # Add more file path here
]
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
files = []
opened_files = []
 
for i, file_path in enumerate(file_path):
    file_obj = open(file_path, 'rb')
    files.append(('images', ('image{}.jpg'.format(i+1), file_obj, 'image/jpeg')))
    opened_files.append(file_obj)
 
response = requests.post(endpoint, headers=headers, files=files)
 
print(response.status_code)
print(response.json())

Example Response

{
    "task_id": "5a5a81b1-406e-415e-9d62-a00ac5ec149b",
    "success": true,
    "message": "request Content-Type isn't multipart/form-data"
}

Fetch

POST

https://api.midjourneyapi.xyz/mj/fetch

The fetch endpoint retrieves result using task_id.

Parameters:

Body
NameTypeRequiredDescription
task_idstring✔️Returned by the task_id parameter in the response upon generation request

Response Codes:

200: OK
Successful Response
400: Bad Request
The request format does not meet the requirements.
401: Unauthorized
The API key is incorrect
500: Internal Server Error
Service is experiencing an error

Example Request

import requests
 
endpoint = "https://api.midjourneyapi.xyz/mj/fetch"
 
data = {
    "task_id": "c0295660-4710-4b09-8fc4-73ed09b114ec"
} 
 
response = requests.post(endpoint, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "task_id": "07b566fa-659d-44a8-8d87-09d9a4b4b037",
    "status": "finished",
    "task_type": "imagine",
    "origin_task_id": "",
    "duration_seconds": 203.689810554,
    "task_request": {
        "prompt": "a running cat in jungle",
        "task_id": "07b566fa-659d-44a8-8d87-09d9a4b4b037"
    },
    "task_result": {
        "image_url": "https://img.midjourneyapi.xyz/mj/zhy0.__a_running_cat_in_jungle_875b0fba-a1ba-4fc6-bb9d-4b0fc1f690c0.png"
    },
    "message": ""
}