Midjourney接口文档
Midjourney API Documentation
Section titled “Midjourney API Documentation”Midjourney Image Formats (Midjourney Proxy/Midjourney Proxy Plus)
Section titled “Midjourney Image Formats (Midjourney Proxy/Midjourney Proxy Plus)”:memo: Introduction
Section titled “:memo: Introduction”Midjourney is a powerful image generation and editing model that can create, edit, and modify images based on natural language descriptions. By exposing different endpoints, it supports a wide range of image generation and processing tasks.
:arrows_counterclockwise: Workflow Diagram
Section titled “:arrows_counterclockwise: Workflow Diagram”
Workflow Overview
Section titled “Workflow Overview”- Initial Task
- Imagine: Text-to-image
- Blend: Multi-image blending
- Describe: Image description
- Swap Face: Face replacement
- Image Processing
- U1-U4: Upscaling
- V1-V4: Variation generation
- Pan: Image panning
- Zoom: Image scaling
- Special Workflows
- Action + Modal: Operations that require a confirmation dialog
- Action direct execution: Operations that do not require a confirmation dialog
- Task Management
- Get task details
- Get image seed
- Upload to Discord
:bulb: Request Examples
Section titled “:bulb: Request Examples”Submit Imagine Task :check_mark_button:
Section titled “Submit Imagine Task :check_mark_button:”curl --location --request POST 'https://api.4allapi.com/mj/submit/imagine' \--header 'Authorization: Bearer $API_KEY' \--header 'Accept: application/json' \--header 'Content-Type: application/json' \--data-raw '{ "botType": "MID_JOURNEY", "prompt": "Cat", "base64Array": [], "accountFilter": { "channelId": "", "instanceId": "", "modes": [], "remark": "", "remix": true, "remixAutoConsidered": true }, "notifyHook": "", "state": ""}'Response example:
{ "code": 1, "description": "Submitted successfully", "properties": {}, "result": 1320098173412546}Submit Blend Task :check_mark_button:
Section titled “Submit Blend Task :check_mark_button:”curl --location --request POST 'https://api.4allapi.com/mj/submit/blend' \--header 'Authorization: Bearer $API_KEY' \--header 'Accept: application/json' \--header 'Content-Type: application/json' \--data-raw '{ "botType": "MID_JOURNEY", "base64Array": [ "data:image/png;base64,xxx1", "data:image/png;base64,xxx2" ], "dimensions": "SQUARE", "accountFilter": { "channelId": "", "instanceId": "", "modes": [], "remark": "", "remix": true, "remixAutoConsidered": true }, "notifyHook": "", "state": ""}'Response example:
{ "code": 1, "description": "Submitted successfully", "properties": {}, "result": 1320098173412546}Submit Describe Task :check_mark_button:
Section titled “Submit Describe Task :check_mark_button:”curl --location --request POST 'https://api.4allapi.com/mj/submit/describe' \--header 'Authorization: Bearer $API_KEY' \--header 'Accept: application/json' \--header 'Content-Type: application/json' \--data-raw '{ "botType": "MID_JOURNEY", "base64": "data:image/png;base64,xxx", "accountFilter": { "channelId": "", "instanceId": "", "modes": [], "remark": "", "remix": true, "remixAutoConsidered": true }, "notifyHook": "", "state": ""}'Response example:
{ "code": 1, "description": "Submitted successfully", "properties": {}, "result": 1320098173412546}Submit Modal :check_mark_button:
Section titled “Submit Modal :check_mark_button:”curl --location --request POST 'https://api.4allapi.com/mj/submit/modal' \--header 'Authorization: Bearer $API_KEY' \--header 'Accept: application/json' \--header 'Content-Type: application/json' \--data-raw '{ "maskBase64": "", "prompt": "", "taskId": "14001934816969359"}'Response example:
{ "code": 1, "description": "Submitted successfully", "properties": {}, "result": 1320098173412546}Submit swap_face Task :check_mark_button:
Section titled “Submit swap_face Task :check_mark_button:”curl --location --request POST 'https://api.4allapi.com/mj/insight-face/swap' \--header 'Authorization: Bearer $API_KEY' \--header 'Accept: application/json' \--header 'Content-Type: application/json' \--data-raw '{ "sourceBase64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RDnYdriP1wsS81kwU8OVs/R3xu8s6bX7+zYnOH8coSqpmRSBjqerjcBlr2OB/lbAf/2Q==", "targetBase64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD849k="}'Response example:
{ "code": 0, "description": "string", "result": "string"}Execute Action :check_mark_button:
Section titled “Execute Action :check_mark_button:”curl --location --request POST 'https://api.4allapi.com/mj/submit/action' \--header 'Authorization: Bearer $API_KEY' \--header 'Accept: application/json' \--header 'Content-Type: application/json' \--data-raw '{ "chooseSameChannel": true, "customId": "MJ::JOB::upsample::1::82c51c9d-bc33-4c07-a471-36c3dcb1a6f0", "taskId": "1728781324658687", "accountFilter": { "channelId": "", "instanceId": "", "modes": [], "remark": "", "remix": true, "remixAutoConsidered": true }, "notifyHook": "", "state": ""}'Response example:
{ "code": 1, "description": "Submitted successfully", "properties": {}, "result": 1320098173412546}Upload Files to Discord :check_mark_button:
Section titled “Upload Files to Discord :check_mark_button:”curl --location --request POST 'https://api.4allapi.com/mj/submit/upload-discord-images' \--header 'Authorization: Bearer $API_KEY' \--header 'Accept: application/json' \--header 'Content-Type: application/json' \--data-raw '{ "base64Array": [], "filter": { "channelId": "", "instanceId": "", "remark": "" }}'Response example:
{ "code": 0, "description": "string", "result": [ "string" ]}Query Tasks by ID List :check_mark_button:
Section titled “Query Tasks by ID List :check_mark_button:”curl --location --request POST 'https://api.4allapi.com/mj/task/list-by-condition' \--header 'Accept: application/json' \--header 'Authorization: Bearer $API_KEY' \--header 'Content-Type: application/json' \--data-raw '{ "ids": []}'Response example:
[ { "action": "IMAGINE", "buttons": [ { "customId": "string", "emoji": "string", "label": "string", "style": 0, "type": 0 } ], "description": "string", "failReason": "string", "finishTime": 0, "id": "string", "imageUrl": "string", "progress": "string", "prompt": "string", "promptEn": "string", "properties": {}, "startTime": 0, "state": "string", "status": "NOT_START", "submitTime": 0 }]Get a Task by ID :check_mark_button:
Section titled “Get a Task by ID :check_mark_button:”curl --location --request GET 'https://api.4allapi.com/mj/task/{id}/fetch' \--header 'Accept: application/json' \--header 'Authorization: Bearer $API_KEY' \--header 'Content-Type: application/json'Response example:
{ "action": "IMAGINE", "buttons": [ { "customId": "string", "emoji": "string", "label": "string", "style": 0, "type": 0 } ], "description": "string", "failReason": "string", "finishTime": 0, "id": "string", "imageUrl": "string", "progress": "string", "prompt": "string", "promptEn": "string", "properties": {}, "startTime": 0, "state": "string", "status": "NOT_START", "submitTime": 0}Get the Image Seed for a Task :check_mark_button:
Section titled “Get the Image Seed for a Task :check_mark_button:”curl --location --request GET 'https://api.4allapi.com/mj/task/{id}/image-seed' \--header 'Accept: application/json' \--header 'Authorization: Bearer $API_KEY' \--header 'Content-Type: application/json'Response example:
{ "code": 0, "description": "string", "result": "string"}:postbox: Requests
Section titled “:postbox: Requests”Endpoints
Section titled “Endpoints”Submit Imagine Task
Section titled “Submit Imagine Task”POST /mj/submit/imagineCreate an image from a text prompt.
Submit Blend Task
Section titled “Submit Blend Task”POST /mj/submit/blendBlend multiple input images to generate a new image.
Submit Describe Task
Section titled “Submit Describe Task”POST /mj/submit/describeGenerate a text description from an input image.
Submit Modal
Section titled “Submit Modal”POST /mj/submit/modalSubmit modal information for fine-tuning image generation details.
Submit swap_face Task
Section titled “Submit swap_face Task”POST /mj/insight-face/swapPerform face swapping between a source image and a target image.
Execute Action
Section titled “Execute Action”POST /mj/submit/actionPerform follow-up actions on a generated image, such as upscaling or adjustments.
Upload Files to Discord
Section titled “Upload Files to Discord”POST /mj/submit/upload-discord-imagesUpload images to the Discord platform.
Query Tasks by ID List
Section titled “Query Tasks by ID List”POST /mj/task/list-by-conditionQuery task details by a specified list of task IDs.
Get a Task by ID
Section titled “Get a Task by ID”GET /mj/task/{id}/fetchGet task details by task ID.
Get the Image Seed for a Task
Section titled “Get the Image Seed for a Task”GET /mj/task/{id}/image-seedGet the seed value of the image generated for the specified task.
Authentication
Section titled “Authentication”Include the following header to authenticate with your API key:
Authorization: Bearer $API_KEYWhere $API_KEY is your API key.
Request Body Parameters
Section titled “Request Body Parameters”Submit Imagine Task
Section titled “Submit Imagine Task”botType
Section titled “botType”- Type: enum string
- Required: No
- Default: MID_JOURNEY
- Options:
MID_JOURNEY: Midjourney modelNIJI_JOURNEY: Niji Journey model
- Description: Selects the bot type to use
prompt
Section titled “prompt”- Type: string
- Required: Yes
- Description: The text prompt used for image generation
- Notes:
- Use clear and specific descriptions
- You can include artistic style, composition, and other details
- English and Chinese inputs are supported
base64Array
Section titled “base64Array”- Type: string array
- Required: No
- Description: Base64-encoded image array for image references
- Format: Each element should be a complete base64 image string, including the MIME type prefix
accountFilter
Section titled “accountFilter”- Type: object
- Required: No
- Properties:
channelId: Channel IDinstanceId: Account instance IDmodes: Array of account modes; options: RELAX, FAST, TURBOremark: Content included in the remarkremix: Whether the account supports remixremixAutoConsidered: Remix auto-submit setting
notifyHook
Section titled “notifyHook”- Type: string
- Required: No
- Description: Callback URL after the task is completed; if empty, the global notifyHook is used
- Type: string
- Required: No
- Description: Custom state parameter for request tracking
Submit Blend Task
Section titled “Submit Blend Task”base64Array
Section titled “base64Array”- Type: string array
- Required: Yes
- Description: Base64-encoded array of images to blend
- Format: Must contain base64 strings for 2-5 images
dimensions
Section titled “dimensions”- Type: enum string
- Required: No
- Options:
PORTRAIT: 2:3 aspect ratioSQUARE: 1:1 aspect ratioLANDSCAPE: 3:2 aspect ratio
- Description: Aspect ratio setting for the output image
Submit Describe Task
Section titled “Submit Describe Task”base64
Section titled “base64”- Type: string
- Required: Yes
- Description: Base64-encoded image to be described
- Format: Complete base64 string, including the MIME type prefix
Submit Modal Task
Section titled “Submit Modal Task”maskBase64
Section titled “maskBase64”- Type: string
- Required: No
- Description: Base64-encoded mask image for partial inpainting
prompt
Section titled “prompt”- Type: string
- Required: No
- Description: Text prompt for the inpainted area
taskId
Section titled “taskId”- Type: string
- Required: Yes
- Description: ID of the original task
Submit Swap Face Task
Section titled “Submit Swap Face Task”sourceBase64
Section titled “sourceBase64”- Type: string
- Required: Yes
- Description: Base64-encoded source image for the face
- Requirement: The image must contain a clear face
targetBase64
Section titled “targetBase64”- Type: string
- Required: Yes
- Description: Base64-encoded target image
- Requirement: The image must contain the face to be replaced
Execute Action
Section titled “Execute Action”chooseSameChannel
Section titled “chooseSameChannel”- Type: boolean
- Required: No
- Default: false
- Description: Whether to select an account in the same channel
customId
Section titled “customId”- Type: string
- Required: Yes
- Description: Action identifier
- Format: A string in a specific format, such as “MJ::JOB::upsample::1::xxx”
taskId
Section titled “taskId”- Type: string
- Required: Yes
- Description: The task ID on which to perform the action
Upload Files to Discord
Section titled “Upload Files to Discord”base64Array
Section titled “base64Array”- Type: string array
- Required: Yes
- Description: Array of base64-encoded images to upload
filter
Section titled “filter”- Type: object
- Required: No
- Properties:
channelId: Target channel IDinstanceId: Account instance IDremark: Remark information
Query Tasks by ID List
Section titled “Query Tasks by ID List”- Type: string array
- Required: Yes
- Description: List of task IDs to query
Common Response Format
Section titled “Common Response Format”All endpoints return a similar response structure:
- Type: integer
- Description: Status code
| Status Code | Description |
|---|---|
| 1 | Submitted successfully |
| 22 | Task queued |
| 21 | Invalid parameters |
| 23 | System error |
| 24 | Account unavailable |
| 25 | Insufficient balance |
description
Section titled “description”- Type: string
- Description: Response message
properties
Section titled “properties”- Type: object
- Description: Extended properties
result
Section titled “result”- Type: string or array
- Description: Return value, which may be a task ID or other data
:inbox_tray: Responses
Section titled “:inbox_tray: Responses”Success Response
Section titled “Success Response”action
Section titled “action”- Type: enum string
- Description: Task type
| String Value | Description |
|---|---|
IMAGINE | Create image |
UPSCALE | Upscale image |
VARIATION | Generate variations |
ZOOM | Zoom image |
PAN | Pan image |
DESCRIBE | Image description |
BLEND | Blend images |
SHORTEN | Shorten prompt |
SWAP_FACE | Face replacement |
buttons
Section titled “buttons”- Type: array of objects
- Description: Action buttons that can be executed
| Array Field | Description |
|---|---|
customId | Action identifier |
emoji | Button icon |
label | Button text |
style | Style (2=Primary, 3=Green) |
type | Internal system type |
description
Section titled “description”- Type: string
- Description: Task description
failReason
Section titled “failReason”- Type: string
- Description: Reason the task failed
finishTime
Section titled “finishTime”- Type: integer
- Description: Task completion timestamp
- Type: string
- Description: Unique task identifier
imageUrl
Section titled “imageUrl”- Type: string
- Description: URL of the generated image
progress
Section titled “progress”- Type: string
- Description: Task progress information
prompt
Section titled “prompt”- Type: string
- Description: Original prompt
promptEn
Section titled “promptEn”- Type: string
- Description: English prompt
status
Section titled “status”- Type: enum string
- Description: Task status
| String Value | Description |
|---|---|
NOT_START | Not started |
SUBMITTED | Submitted |
MODAL | Modal in progress |
IN_PROGRESS | In progress |
FAILURE | Failed |
SUCCESS | Successful |
CANCEL | Canceled |
submitTime
Section titled “submitTime”- Type: integer
- Description: Task submission timestamp
startTime
Section titled “startTime”- Type: integer
- Description: Task start timestamp
Error Response
Section titled “Error Response”When a request encounters a problem, the API returns an error response:
HTTP Status Codes
Section titled “HTTP Status Codes”400 Bad Request: Invalid request parameters401 Unauthorized: API key is invalid or missing403 Forbidden: Insufficient permissions404 Not Found: Resource not found429 Too Many Requests: Rate limit exceeded500 Internal Server Error: Internal server error
Error Response Format
Section titled “Error Response Format”{ "code": <error_code>, "description": "Error description", "result": null}