Midjourney API V2

Midjourney API V2

Documentation of Version 2 of all available Midjourney API endpoints, and their headers, body, sample requests and responses.

Mode

Our Midjourney API V2 provides relax, fast, and turbo modes of image generation, corresponding to their Midjourney equivalents.

Mode Selection

Please use the process_mode parameter in the API body to select modes (please refrain from using the in-prompt-mode to select modes).

A screenshot showing GoAPI's process modes

Below are rules about mode selection:

  1. If the process mode is not specified, system will default to the in-prompt-mode. If the in-prompt-mode is also not specified, then the system default is relax mode. For example:
    1. If process mode = "" & in-prompt-mode = relax | will use relax
    2. If process mode = "" & in-prompt-mode = fast | will use fast
    3. If process mode = "" & in-prompt-mode = unspecified | will use relax
  2. Process mode overrides in-prompt-mode; for example:
    1. If process mode = fast & in-prompt-mode = relax | will use fast
    2. If process mode = relax & in-prompt-mode = fast | will use relax
  3. For BYOA users, rules will apply depending on the available resource of your Midjourney account(s). For example:
    1. Fast or turbo jobs will be routed to any accounts with available fast hours. If none is available, the job will be processed as a relax job on any accounts with relax GPU time.
    2. Relax jobs will be routed to any accounts that is not on the Basic Plan (the $10 plan) because this plan has no relax GPU time. If none is available, then an error will be returned.
    3. If your only Midjourney account's account setting is relax, then all the jobs processed by this account will be relax mode regardless mode selection from GoAPI. Also, when you set your Midjourney account to relax mode, we will not use it for any fast job, and this might result in wasted fast hours.
    4. If your Midjourney account's setting is fast, then all jobs will be processed as per mode selection from GoAPI. When your Midjourney account runs out of fast hours, we will automatically change that account's setting to relax.

Note:

  1. Endpoints such as upscale, variation, outpaint, and pan don’t support process mode. Instead, they inherit the process mode from the parent task automatically.

Endpoints

Below is a typical workflow diagram with available Midjourney API endpoints from GoAPI:

A screenshot of a typical workflow diagram with Midjourney API from GoAPI



Imagine

POST

https://api.midjourneyapi.xyz/mj/v2/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 image processing
skip_prompt_checkbooleanbypass internal prompt validation process. Default value: False
aspect_ratiostringAspect ratio of the image default value: 1:1
process_modestringWhich mode to use for processing valid values: relax/fast/turbo
webhook_endpointstringSend a request to the address contained in the string for task completion notification. It must be in the form of https://domain and only port 443 can be used. No request will be sent if left blank
webhook_secretstringPassed as the x-webhook-secret field in the headers during the request. The default value is empty.

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

Writing Midjourney prompt just like you would like write prompt in the Discord community with /imagine command.


Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/v2/imagine"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "prompt": "a cute cat",
    "aspect_ratio": "4:3",
    "process_mode": "fast",
    "webhook_endpoint": "",
    "webhook_secret": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "task_id": "807400b9-9d79-465b-8ecc-eecb7419dbbc",
    "status": "success",
    "message": ""
}


Reroll

POST

https://api.midjourneyapi.xyz/mj/v2/reroll

The reroll endpoint re-draws based on prompts and parent task.

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
origin_task_idstring✔️The task ID of the original task
promptstringPrompt for re-drawing default value: original prompt from parent task
skip_prompt_checkbooleanbypass internal prompt validation process. Default value: False
aspect_ratiostringAspect ratio of the image default value: 1:1
webhook_endpointstringSend a request to the address contained in the string for task completion notification. It must be in the form of https://domain and only port 443 can be used. No request will be sent if left blank
webhook_secretstringPassed as the x-webhook-secret field in the headers during the request. The default value is empty.

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/v2/reroll"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "origin_task_id": "cbf31ba7-c83b-4cb4-a875-ff60e499e0bc",
    "prompt": "a cute cartoon blue cat, weird",
    "aspect_ratio": "4:3"
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
  'task_id': '9cd1c5e3-52a8-4b3f-8dbc-4a13a772fcbe',
  'status': 'success',
  'message': ''
}


Upscale

POST

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

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

Parameters:

Header
NameTypeRequiredDescription
X-API-KEYstring✔️Your API Key used for request authorization
Body
NameTypeRequiredDescription
origin_task_idstring✔️The returned task_id from your parent request
indexstring✔️ The index of the image to upscale. Valid values: 1/2/3/4/2x/4x/light/beta/subtle/creative;
Light/beta are only available for V4 jobs, 2x/4x for V5 tasks, subtle/creative for V6 tasks. Check Midjourney official guide for more info.
webhook_endpointstringSend a request to the address contained in the string for task completion notification. It must be in the form of https://domain and only port 443 can be used. No request will be sent if left blank
webhook_secretstringPassed as the x-webhook-secret field in the headers during the request. The default value is empty.

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
  • The 'process_mode' parameter is not supported for this endpoint, it is automatically inherited from the parent task (origin_task_id).
  • If you want to do an upscale 4x for example, you'd have to use this upscale endpoint to first upscale one of the four images returned from the imagine endpoint; and call this upscale endpoint again with index '4x' and use the taskID of the previous upscale task for the 'origin_task_id' parameter.

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/v2/upscale"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "origin_task_id": "e5caaac5-4a6d-4078-b2d3-b973d907b611",
    "index": "1",
    "webhook_endpoint": "",
    "webhook_secret": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "task_id": "e5caaac5-4a6d-4078-b2d3-b973d907b611",
    "status": "success",
    "message": ""
}


Variation

POST

https://api.midjourneyapi.xyz/mj/v2/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✔️ Image index to upscaled - valid values can be 1, 2, 3, 4, high_variation, & low_variation.
High_variation and low_variation are only for V5.2 and V6 (high is vary_strong, low is vary_subtle)
promptstringDrawing prompt default value: prompt from the parent task
skip_prompt_checkstringbypass internal prompt validation process. Default value: False
aspect_ratiostringAspect ratio of the image default value: 1:1
webhook_endpointstringSend a request to the address contained in the string for task completion notification. It must be in the form of https://domain and only port 443 can be used. No request will be sent if left blank
webhook_secretstringPassed as the x-webhook-secret field in the headers during the request. The default value is empty.

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
  • The 'process_mode' parameter is not supported for this endpoint, it is automatically inherited from the parent task (origin_task_id).

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/v2/variation"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "origin_task_id": "45ffd445-28cf-45fc-9ac5-7ee5d426c901",
    "index": "1",
    "prompt": "a cute cat with a hat",
    "aspect_ratio": "3:4"
    "webhook_endpoint": "",
    "webhook_secret": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "task_id": "e5caaac5-4a6d-4078-b2d3-b973d907b611",
    "status": "success",
    "message": ""
}


Inpaint

POST

https://api.midjourneyapi.xyz/mj/v2/inpaint

The inpaint endpoint partial modifies of the 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
maskstring✔️Base64 encoding of the image corresponding to the selected area
promptstringDrawing prompt for selected areas
skip_prompt_checkbooleanbypass internal prompt validation process. Default value: False
webhook_endpointstringSend a request to the address contained in the string for task completion notification. It must be in the form of https://domain and only port 443 can be used. No request will be sent if left blank
webhook_secretstringPassed as the x-webhook-secret field in the headers during the request. The default value is empty.

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

Midjourney Inpainting UI is a simple tool to replicate Midjourney's inpainting model interface. You can generate mask base64 code using this open-source tool.

Example Request

import requests
import json
 
url = "https://api.midjourneyapi.xyz/mj/v2/inpaint"
 
payload = json.dumps({
  "origin_task_id": "1d536e18-c8a8-4ac5-9c4b-ae5895cc1f29",
  "prompt": "mirror",
  "skip_prompt_check": False,
  "mask": "UklGRuoVAABXRUJQVlA4WAoAAAAgAAAAzwQAnwMASUNDUMgBAAAAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0AAABUAAAABRyVFJDAAABZAAAAChnVFJDAAABZAAAAChiVFJDAAABZAAAAChjcHJ0AAABjAAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9YWVogAAAAAAAA9tYAAQAAAADTLXBhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAC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Gksh0CDYJhEJvLmCVUwMiUFSba0u2aa27MPVg1aaZqkm/E4a7Uhes1sDKxaTO78suqzXcRKTi2BwZ3fiGXNUmSc098R868EFXULl7CMUeKADQgs+jM5vh6p7r0BkVdZo5BqwMeEhMPSDU3p2F47kU4+VEnmZySJiPojwJ5fy8pXV3WmbmXei0FUrYcQNrTW4Y+cP/ZIN5TfBKxDg5oeF7nntU0edaB/efIj5w/7Z8V/QlAISNqIpx/oCfrX2yHMY/AaOt/39NV26lv8VW9MNkooLeeCZ2hVmstN5rmRS5kemQMX7UpcAA3PdLzalUnlX8FS+65l/83/kUNrstWvZem9QGQYYFzbZAAAAAAAAAAAAAAAAAAAAAAAAAA="
})
headers = {
  'X-API-Key': 'YOUR_API_KEY',
  'Content-Type': 'application/json'
}
 
response = requests.request("POST", url, headers=headers, data=payload)
 
print(response.text)
 

Example Response

{
    "task_id": "807400b9-9d79-465b-8ecc-eecb7419dbbc",
    "status": "success",
    "message": ""
}


Outpaint

POST

https://api.midjourneyapi.xyz/mj/v2/outpaint

The outpaint endpoint enlarges an image's canvas beyond its original size while keeping the contents of the original image unchanged.

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
zoom_ratiostring Applicable values:
 - For MJ button "zoom out 1.5x",    enter: 1.5
 - For MJ button "zoom out 2x",    enter: 2
 - For MJ button "custom zoom",    enter: (1, 2]
 - For MJ button "make square",    enter: 1
aspect_ratiostringAspect ratio of the image default value 1:1
promptstringThe prompt for image processing
skip_prompt_checkbooleanbypass internal prompt validation process. Default value: False
webhook_endpointstringSend a request to the address contained in the string for task completion notification. It must be in the form of https://domain and only port 443 can be used. No request will be sent if left blank
webhook_secretstringPassed as the x-webhook-secret field in the headers during the request. The default value is empty.

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

The 'process_mode' parameter is not supported for this endpoint, it is automatically inherited from the parent task.

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/v2/outpaint"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "origin_task_id": "45ffd445-28cf-45fc-9ac5-7ee5d426c901",
    "zoom_ratio": "2",
    "aspect_ratio": "4:3",
    "prompt": "a cute cat with a hat",
    "webhook_endpoint": "",
    "webhook_secret": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "task_id": "e5caaac5-4a6d-4078-b2d3-b973d907b611",
    "status": "success",
    "message": ""
}


Pan

POST

https://api.midjourneyapi.xyz/mj/v2/pan

The pan endpoint broadens the image canvas in a specific direction, keeping the original content intact and using prompts and the original image as guides for filling the expanded area.

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
directionstringImage expansion direction valid values: up/down/left/right
promptstringThe prompt for image processing
skip_prompt_checkbooleanbypass internal prompt validation process. Default value: False
webhook_endpointstringSend a request to the address contained in the string for task completion notification. It must be in the form of https://domain and only port 443 can be used. No request will be sent if left blank
webhook_secretstringPassed as the x-webhook-secret field in the headers during the request. The default value is empty.

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

The 'process_mode' parameter is not supported for this endpoint, it is automatically inherited from the parent task.

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/v2/pan"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "origin_task_id": "45ffd445-28cf-45fc-9ac5-7ee5d426c901",
    "direction": "left",
    "prompt": "a cute cat with a hat",
    "webhook_endpoint": "",
    "webhook_secret": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())
 

Example Response

{
  "task_id": "43507b86-1495-44f5-ac89-40d15dccc729",
  "status": "success",
  "message": ""
}


Describe

POST

https://api.midjourneyapi.xyz/mj/v2/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
image_urlstring✔️Image URL path
process_modestringWhich mode to use for processing valid values: relax/fast/turbo
webhook_endpointstringSend a request to the address contained in the string for task completion notification. It must be in the form of https://domain and only port 443 can be used. No request will be sent if left blank
webhook_secretstringPassed as the x-webhook-secret field in the headers during the request. The default value is empty.

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
  • Note: Discord CDN links will not work with this endpoint.

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/v2/describe"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "image_url": "https://sample.png",
    "process_mode": "fast",
    "webhook_endpoint": "",
    "webhook_secret": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())
 

** Example Response

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


Blend

POST

https://api.midjourneyapi.xyz/mj/v2/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
image_urlsstring✔️Image URL path list, containing 2 to 5 items.
process_modestringWhich mode to use for processing valid values: relax/fast/turbo
webhook_endpointstringSend a request to the address contained in the string for task completion notification. It must be in the form of https://domain and only port 443 can be used. No request will be sent if left blank
webhook_secretstringPassed as the x-webhook-secret field in the headers during the request. The default value is empty.
dimensionstringvalid values: square/portrait/landscape see: https://docs.midjourney.com/docs/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
  • Note: Discord CDN links will not work with this endpoint.

Example Request

import requests
 
X-API-KEY = "YOUR_API_KEY" 
 
endpoint = "https://api.midjourneyapi.xyz/mj/v2/blend"
 
headers = {
    "X-API-KEY": X-API-KEY
}
 
data = {
    "image_urls": [
        "https://sample1.png",
        "https://sample2.png"
    ],
    "process_mode": "fast",
    "webhook_endpoint": "",
    "webhook_secret": ""
}
 
response = requests.post(endpoint, headers=headers, json=data)
 
print(response.status_code)
print(response.json())
 

Example Response

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


Seed

POST

https://api.midjourneyapi.xyz/mj/v2/seed

The seed endpoint get seed information in fetched result

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

Screenshot of GoAPI seed workflow

Make a request to /imagine , then make a seed request with task_id to get a new task_id, then fetch the result; you will receive a seed value in task_result.

Example Request

import requests
 
endpoint = "https://api.midjourneyapi.xyz/mj/v2/seed"
 
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": "c319e01f-1a06-4fba-bcfa-b92890805151",
    "status": "success",
    "message": ""
}


CreateTaskResponse

Unified response format for all the above create task requests.

ParameterDescription
task_idTask id
status

Task creation result:

- success: task creation was successful.

- failed: task creation was unsuccessful.

message

Error message, possible causes for task creation failure:

- Body parsing failed.

- Original task does not exist.

- Task with same index already created.

- Insufficient credit balance.

Example Response Format

// sample create task success
{
    "task_id": "e5caaac5-4a6d-4078-b2d3-b973d907b611",
    "status": "success",
    "message": ""
}


Fetch

POST

https://api.midjourneyapi.xyz/mj/v2/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/v2/fetch"
 
data = {
    "task_id": "c0295660-4710-4b09-8fc4-73ed09b114ec"
} 
 
response = requests.post(endpoint, json=data)
 
print(response.status_code)
print(response.json())

General response

ParameterDescription
task_idTask id
task_typetask type
process_time

task processing time(/second)

- total elapsed time is displayed when the task is in the finished/failed state.

- the currently calculated elapsed time is displayed when the task is in other states.

status

Current status of the task, valid values:

- pending: The task is waiting to be executed in the queue.

- staged: The task is cached, not in the queue yet.

- processing: The task is being executed.

- finished: The task has been completed.

- failed: The task execution failed.

- retry: The task is waiting in the queue to be retried.

task_resultShowing task result, please check Midjourney Task Result for more information.
metaTask metadata, which does not change after the task is created.

Meta

ParameterDescription
created_atThe time the task was created, represented as a timestamp in seconds
started_atThe time the task was started, represented as a timestamp in seconds
created_atTask creation time
started_atThe time when the task started execution
process_modeThe mode of the bot processing this task
task_requestUser's original request information - please ignore
task_paramPlease ignore all parameters and values inside task_param

Task_result

Showing task result, please check Midjourney Task Result for more information.


Example Response

{
    "task_id": "fa53c448-0092-49e8-8538-c9353945e714",
    "process_time": 48.2175553,
    "status": "finished",
    "task_result": {
        "discord_url": "https://cdn.discordapp.com/example",
        "image_url": "https://img.midjourneyapi.xyz/example",
        "image_id": "a26849cc-76d6-4642-9a77-873ea014d1b0",
        "result_message_id": "1141319184609976440",
        "credit": 7,
        "message": "",
        "error_messages": [],
        "service_unavailable": false,
        "need_retry": false,
        "warn_notify": false
    },
    "meta": {
        "account_id": "",
        "task_type": "imagine",
        "origin_task_id": "",
        "multi_bots": false,
        "created_at": 1692182109,
        "started_at": 1692182150,
        "process_mode": "fast",
        "frozen_credit": 7,
        "task_request": {
            "prompt": "a cute cat",
            "process_mode": "fast",
        },
        "task_input": {
            "prompt": "a cute cat",
            "index": "",
            "zoom_ratio": "2",
            "aspect_ratio": "1:1",
            "direction": ""
        }
    }
}

Multi Fetch

POST

https://api.goapi.xyz/mj/v2/multi_fetch

The multifetch endpoint retrieves multiple task results using multiple task_id.

Parameters:

Body
NameTypeRequiredDescription
task_idsarray✔️An array of task id string, no more than 50 ids

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.goapi.xyz/mj/v2/multi_fetch"
 
data = {
    "task_ids": ["c0295660-4710-4b09-8fc4-73ed09b114ec", "0cbaf671-d3bf-482c-ad25-db147180a251"]
} 
 
response = requests.post(endpoint, json=data)
 
print(response.status_code)
print(response.json())

Example Response

{
    "code": 200,
    "data": {
        "87d78899-85d9-4be9-a714-8b7379f7ce44": {
            "task_id": "87d78899-85d9-4be9-a714-8b7379f7ce44",
            "status": "processing",
            "process_time": 0,
            "retry_count": 0,
            "meta": {
                "account_id": "333",
                "task_type": "imagine",
                "origin_task_id": "",
                "bot_hash": "",
                "bot_id": 435,
                "process_mode": "relax",
                "quota_frozen": 9,
                "frozen_credit": 0,
                "created_at": 1702364556,
                "started_at": 1702364557,
                "ended_at": 0,
                "task_request": {
                    "aspect_ratio": "4:3",
                    "auto_upload": false,
                    "process_mode": "relax",
                    "prompt": "a cat",
                    "skip_prompt_check": false,
                    "webhook_endpoint": "https://webhook.site/99f42b2b-be05-499b-8887-dd30764ab15b",
                    "webhook_secret": "hello"
                },
                "task_param": {
                    "prompt": "a cat --relax",
                    "index": "",
                    "zoom_ratio": "2",
                    "aspect_ratio": "4:3",
                    "direction": ""
                }
            },
            "task_result": {
                "discord_image_url": "",
                "image_url": "",
                "permanent_url": "",
                "image_id": "",
                "seed": "",
                "result_message_id": "",
                "quota_used": 0,
                "credit": 0,
                "message": "",
                "error_messages": [],
                "need_retry": true,
                "actions": [
                    "reroll",
                    "upscale1",
                    "upscale2",
                    "upscale3",
                    "upscale4",
                    "variation1",
                    "variation2",
                    "variation3",
                    "variation4"
                ]
            }
        },
        "87d78899-85d9-4be9-a714-8b7379f7ce45": null
    },
    "message": "success"
}