MidJourney API Notes
The MidJourney API is divided into two categories: Direct Generation and Secondary Editing. Direct Generation only requires providing necessary parameters such as prompts to generate images directly. Secondary Editing requires providing the previous task ID and image number to execute image generation. uploadpaint is a Direct Generation category
Authentication
authorization string required
All APIs require authentication via Bearer Token.
Get API Key:
Visit API Key Management Page to get your API Key
Usage:
Add to request header:
Authorization: Bearer YOUR_API_KEY
Parameters
model string required
Model ID to use for the request
Options: midjourney_uploadpaint
imgUrl string required
Image URL, must be valid HTTP/HTTPS URL, length not exceeding 1024 characters
canvas object required
Canvas object
width
integerrequiredWidth in pixels
height
integerrequiredHeight in pixels
imgPos object required
Image position and size relative to canvas
x
integerrequiredHorizontal offset from the top-left corner of canvas
y
integerrequiredVertical offset from the top-left corner of canvas
width
integerrequiredWidth in pixels
height
integerrequiredHeight in pixels
mask object required
Mask parameters, must contain areas or url
areas
arrayArray of mask area objects
width
integerArea width
height
integerArea height
points
arrayArray of area coordinate points, must contain at least 6 coordinate values
url
stringMask image URL
remixPrompt string required
Remix prompt, length must be between 1-8192 characters
callback string
Callback URL, must be valid HTTP/HTTPS URL
Polling
Since result generation takes time, you need to poll the task status after creating the task.
The initial response only returns information such as the task ID and initial status. The final result must be obtained by polling the task status endpoint using the task ID.
See the examples on the right for polling requests and responses.
Response Format
error object
Error information, only present when status is failed
code
integerError code
error_message
stringDetailed error message
output array
Generation results, only present when status is completed
content
arrayList of generated content
type
stringResource type, e.g.,
video,imageurl
stringGenerated content URL
usage object
Usage statistics, only present when status is completed
cost
stringTotal cost in USD
discount
numberDiscount amount
metadata object
Metadata information
Error Codes
| Error Code | Description |
|---|---|
| 004014001 | Image URL missing |
| 004014002 | Invalid image URL length |
| 004014003 | Invalid image URL format |
| 004014004 | Canvas parameters missing |
| 004014005 | Invalid canvas parameters |
| 004014006 | Image position parameters missing |
| 004014007 | Invalid image position parameters |
| 004014008 | Mask parameters missing |
| 004014009 | Invalid mask parameters |
| 004014010 | Remix prompt missing |
| 004014011 | Invalid remix prompt length |
| 004014012 | Invalid callback URL |
| 004014098 | Generation failed |
| 004014099 | Service unavailable |