Midjourney API Reference
Overview
| Property | Value |
|---|---|
| Model ID | midjourney |
| Type | Text-to-Image, Image-to-Image |
| Pricing | Relaxed: $0.04/task ยท Fast: $0.1/task ยท Turbo: $0.2/task (outputs 4 images) |
| Average Time | Relaxed: 250s ยท Fast: 60s ยท Turbo: 30s |
Authentication
All API requests require authentication using a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Endpoints
1. Submit Generation Task
POST https://api.apixo.ai/api/v1/generateTask/midjourney
2. Query Task Status
GET https://api.apixo.ai/api/v1/statusTask/midjourney?taskId={taskId}
Request Parameters
Request Body Structure
{
"request_type": "async",
"callback_url": "https://your-server.com/callback",
"input": {
"mode": "text-to-image",
"prompt": "Your image description",
"speed": "relaxed",
"aspect_ratio": "16:9",
...
}
}
Top-Level Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request_type | string | Yes | Request mode: async (poll results) or callback (webhook notification) |
callback_url | string | No | Webhook URL for callback mode. Must be publicly accessible |
input | object | Yes | Generation parameters (see below) |
Input Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
mode | string | Yes | text-to-image | Generation mode: text-to-image or image-to-image |
prompt | string | Yes | - | Image description (max 2,000 characters) |
speed | string | Yes | relaxed | Speed tier: relaxed ($0.04, 250s), fast ($0.1, 60s), turbo ($0.2, 30s) |
image_urls | string[] | No | - | Up to 2 reference image URLs for image-to-image mode |
aspect_ratio | string | No | 16:9 | Output ratio: 1:1, 1:2, 2:1, 2:3, 3:2, 3:4, 4:3, 5:6, 6:5, 9:16, 16:9 |
version | string | No | 7 | Midjourney model version: 7 |
variety | integer | No | 10 | Image diversity (0-100, increment by 5). Higher = more diverse |
stylization | integer | No | 1 | Artistic style intensity (0-1000, multiple of 50). Higher = more stylized |
weirdness | integer | No | 1 | Creativity level (0-3000, multiple of 100). Higher = more unusual |
watermark | string | No | - | Custom watermark text |
enableTranslation | boolean | No | true | Auto-translate non-English prompts |
Response Format
Task Submission Response
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678"
}
}
Status Query Response
Processing:
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"state": "processing",
"createTime": 1698765400000
}
}
Success:
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"state": "success",
"resultJson": "{\"resultUrls\":[\"https://example.com/image1.jpg\",\"https://example.com/image2.jpg\",\"https://example.com/image3.jpg\",\"https://example.com/image4.jpg\"]}",
"costTime": 55000,
"createTime": 1698765400000,
"completeTime": 1698765455000
}
}
Failed:
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"state": "failed",
"failCode": "CONTENT_VIOLATION",
"failMsg": "Content does not meet safety guidelines",
"createTime": 1698765400000,
"completeTime": 1698765455000
}
}
Response Fields:
| Field | Type | Description |
|---|---|---|
code | integer | HTTP status code (200 = success) |
data.taskId | string | Unique task identifier |
data.state | string | Task state: pending, processing, success, failed |
data.resultJson | string | JSON string with resultUrls array containing 4 images (on success) |
data.costTime | integer | Generation time in milliseconds |
data.failCode | string | Error code (on failure) |
data.failMsg | string | Error message (on failure) |
Callback Response
When the task is completed, the system will send a POST request to your callBackUrl in the following format:
Success Callback
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"state": "success",
"resultJson": "{\"resultUrls\":[\"https://example.com/image1.jpg\",\"https://example.com/image2.jpg\",\"https://example.com/image3.jpg\",\"https://example.com/image4.jpg\"]}",
"completeTime": 1698765455000,
"createTime": 1698765400000,
"costTime": 55000
}
}
Failure Callback
{
"code": 400,
"message": "failed",
"data": {
"taskId": "task_12345678",
"state": "failed",
"failCode": "CONTENT_VIOLATION",
"failMsg": "Content does not meet safety guidelines",
"completeTime": 1698765455000,
"createTime": 1698765400000,
"costTime": 55000
}
}
Quick Start
1. Text-to-Image Generation (Relaxed Speed)
curl -X POST https://api.apixo.ai/api/v1/generateTask/midjourney \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"request_type": "async",
"input": {
"mode": "text-to-image",
"prompt": "A beautiful sunset over the mountains with vibrant colors",
"speed": "relaxed",
"aspect_ratio": "16:9"
}
}'
Response:
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678"
}
}
2. Check Task Status
curl -X GET "https://api.apixo.ai/api/v1/statusTask/midjourney?taskId=task_12345678" \
-H "Authorization: Bearer YOUR_API_KEY"
Response (Success):
{
"code": 200,
"message": "success",
"data": {
"taskId": "task_12345678",
"state": "success",
"resultJson": "{\"resultUrls\":[\"https://example.com/img1.jpg\",\"https://example.com/img2.jpg\",\"https://example.com/img3.jpg\",\"https://example.com/img4.jpg\"]}"
}
}
3. Image-to-Image with Turbo Speed
curl -X POST https://api.apixo.ai/api/v1/generateTask/midjourney \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"request_type": "async",
"input": {
"mode": "image-to-image",
"prompt": "Transform into watercolor painting style",
"image_urls": ["https://example.com/input.jpg"],
"speed": "turbo",
"aspect_ratio": "1:1"
}
}'
Best Practices
Request Mode Selection
| Mode | Use When |
|---|---|
| Callback | Production environments with public server endpoints |
| Async | Client-side apps or when webhook setup is not feasible |
Performance Tips
- Relaxed Mode: Wait 200 seconds before first poll, then poll every 10 seconds
- Fast Mode: Wait 50 seconds before first poll, then poll every 10 seconds
- Turbo Mode: Wait 10 seconds before first poll, then poll every 10 seconds
- Timeout: Set maximum wait time to 5 minutes
- Rate Limiting: Avoid excessive concurrent requests
- Error Handling: Always check
statefield and handle failures gracefully
Resource Management
- Each task generates 4 images - plan storage accordingly
- Image URLs may be temporary - download and store important results
- Clean up failed tasks appropriately
- Log
taskIdfor debugging and support