Midjourney API Reference

Overview

PropertyValue
Model IDmidjourney
TypeText-to-Image, Image-to-Image
PricingRelaxed: $0.04/task ยท Fast: $0.1/task ยท Turbo: $0.2/task (outputs 4 images)
Average TimeRelaxed: 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

ParameterTypeRequiredDescription
request_typestringYesRequest mode: async (poll results) or callback (webhook notification)
callback_urlstringNoWebhook URL for callback mode. Must be publicly accessible
inputobjectYesGeneration parameters (see below)

Input Parameters

ParameterTypeRequiredDefaultDescription
modestringYestext-to-imageGeneration mode: text-to-image or image-to-image
promptstringYes-Image description (max 2,000 characters)
speedstringYesrelaxedSpeed tier: relaxed ($0.04, 250s), fast ($0.1, 60s), turbo ($0.2, 30s)
image_urlsstring[]No-Up to 2 reference image URLs for image-to-image mode
aspect_ratiostringNo16:9Output ratio: 1:1, 1:2, 2:1, 2:3, 3:2, 3:4, 4:3, 5:6, 6:5, 9:16, 16:9
versionstringNo7Midjourney model version: 7
varietyintegerNo10Image diversity (0-100, increment by 5). Higher = more diverse
stylizationintegerNo1Artistic style intensity (0-1000, multiple of 50). Higher = more stylized
weirdnessintegerNo1Creativity level (0-3000, multiple of 100). Higher = more unusual
watermarkstringNo-Custom watermark text
enableTranslationbooleanNotrueAuto-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:

FieldTypeDescription
codeintegerHTTP status code (200 = success)
data.taskIdstringUnique task identifier
data.statestringTask state: pending, processing, success, failed
data.resultJsonstringJSON string with resultUrls array containing 4 images (on success)
data.costTimeintegerGeneration time in milliseconds
data.failCodestringError code (on failure)
data.failMsgstringError 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

ModeUse When
CallbackProduction environments with public server endpoints
AsyncClient-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 state field 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 taskId for debugging and support