Midjourney Best Practices
cometapi Midjourney API Documentation
headers = {"Authorization": "sk-hjbazhiawxxxxxxxxxx"}
1. Submit Imagine (Drawing) Task
API Information
Request Example
{
"base64Array": [],
"notifyHook": "",
"prompt": "Cat",
"state": ""
}
Request Parameters
Parameter Name | Description | Required | Data Type |
---|---|---|---|
base64Array | Array of base64 encoded images | No | array string |
prompt | Text prompt | Yes | string |
state | Custom parameter | No | string |
Response Status
Status Code | Description |
---|---|
200 | OK |
201 | Created |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
Response Parameters
Parameter Name | Description | Type |
---|---|---|
code | Status code: 1(success), 21(already exists), 22(queuing), 4(internal error) | integer(int32) |
description | Description | string |
properties | Extended fields | object |
result | Task ID | string |
Response Example
{
"code": 1,
"description": "Submit success",
"properties": {},
"result": 1320098173412546
}
2. Execute Action
API Information
3. Image Variations
API Information
Request Example
{
"action": "UPSCALE",
"index": 1,
"notifyHook": "",
"state": "",
"taskId": "1320098173412546"
}
Request Parameters
Parameter Name | Description | Required | Data Type |
---|---|---|---|
action | UPSCALE, VARIATION, REROLL | Yes | string |
index | Number (1~4), required when action is UPSCALE or VARIATION | No | integer(int32) |
notifyHook | Callback URL, uses global notifyHook if empty | No | string |
state | Custom parameter | No | string |
taskId | Task ID | Yes | string |
Response Status
Status Code | Description |
---|---|
200 | OK |
201 | Created |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
Response Parameters
Parameter Name | Description | Type |
---|---|---|
code | Status code: 1(success), 21(already exists), 22(queuing), other(error) | integer(int32) |
description | Description | string |
properties | Extended fields | object |
result | Task ID | string |
Response Example
{
"code": 1,
"description": "Submit success",
"properties": {},
"result": 1320098173412546
}
4. Submit Modal (Partial Redraw, Zoom)
API Information
Request Example
{
"maskBase64": "",
"prompt": "",
"taskId": "14001934816969359"
}
Request Parameters
Parameter Name | Description | Required | Data Type |
---|---|---|---|
maskBase64 | Base64 encoded mask for partial redraw | No | string |
prompt | Text prompt | No | string |
taskId | Task ID | Yes | string |
Response Status
Status Code | Description |
---|---|
200 | OK |
201 | Created |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
Response Parameters
Parameter Name | Description | Type |
---|---|---|
code | Status code: 1(success), 21(already exists), 22(queuing), other(error) | integer(int32) |
description | Description | string |
properties | Extended fields | object |
result | Task ID | string |
Response Example
{
"code": 1,
"description": "Submit success",
"properties": {},
"result": 1320098173412546
}
5. Fetch Task by ID
API Information
Request Parameters
Parameter Name | Description | Request Type | Required | Data Type |
---|---|---|---|---|
id | Task ID | path | No | string |
Response Status
Status Code | Description |
---|---|
200 | OK |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
Response Parameters
Parameter Name | Description | Type |
---|---|---|
action | Available values: UPSCALE, VARIATION, REROLL, DESCRIBE, BLEND | string |
description | Task description | string |
failReason | Reason for failure | string |
finishTime | End time | integer(int64) |
id | Task ID | string |
imageUrl | Image URL | string |
progress | Task progress | string |
prompt | Text prompt | string |
promptEn | Text prompt in English | string |
startTime | Start execution time | integer(int64) |
state | Custom parameter | string |
status | Task status: SUBMITTED, IN_PROGRESS, FAILURE, SUCCESS | string |
submitTime | Submission time | integer(int64) |
Response Example
{
"id": "1712310326047513",
"action": "UPSCALE",
"customId": "",
"botType": "",
"prompt": "a lovely Japan countryside --niji 6 --ar 16:9",
"promptEn": "a lovely Japan countryside --niji 6 --ar 16:9",
"description": "Submit success",
"state": "",
"submitTime": 1712310326047,
"startTime": 1712310328336,
"finishTime": 1712310329602,
"imageUrl": "https://api.cometapi.com/mj/image/1712310326047513",
"status": "SUCCESS",
"progress": "100%",
"failReason": "",
"buttons": [
{
"customId": "MJ::JOB::upsample_v6_2x_subtle::1::125fd761-3d07-4252-8513-8a07dce51ce7::SOLO",
"emoji": "upscale_1",
"label": "Upscale (Subtle)",
"type": 2,
"style": 2
},
// ... other button configurations
],
"maskBase64": "",
"properties": {
"finalPrompt": "a lovely Japan countryside --niji 6 --ar 16:9",
"finalZhPrompt": ""
}
}