Skip to main content

Documentation Index

Fetch the complete documentation index at: https://apixo.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Midjourney is an async image model for high-quality text-to-image generation, reference-guided remixing, region editing, variation, and upscaling. Use this page when you are ready to call the API after trying Midjourney in the APIXO playground.
CapabilityValue
Model IDmidjourney
Modestext-to-image, image-to-image, upload-paint, vary, upscale
Prompt lengthNon-empty. Route limits are up to 2000 characters or up to 6000 UTF-8 bytes; keep prompts under 2000 characters for portable requests.
Reference imagesUse exactly 1 image for route-compatible image-to-image or upload-paint requests. Some routes can accept up to 2 images.
Aspect ratios1:1, 1:2, 2:1, 2:3, 3:2, 3:4, 4:3, 5:6, 6:5, 9:16, 16:9
Speedsfast, turbo; relaxed is accepted by validation but is not listed on public pricing
Result countUsually 4 images for generation and variation, usually 1 image for upscale
Do not put Midjourney inline flags such as --ar, --style, or --sref inside prompt. The backend strips prompt text from the first -- onward. Use API fields such as aspect_ratio, stylization, variety, and weirdness instead.

Endpoint and authentication

Base URL:
https://api.apixo.ai/api/v1
MethodEndpointPurpose
POST/generateTask/midjourneySubmit a Midjourney task
GET/statusTask/midjourney?taskId={taskId}Poll task status and retrieve results
All requests require your APIXO API key:
Authorization: Bearer YOUR_API_KEY
Submit requests also require:
Content-Type: application/json

Copy-paste async quickstart

This minimal request submits a text-to-image task and returns a taskId.
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 cinematic product photo of a transparent speaker on black marble",
      "version": "7",
      "speed": "fast",
      "aspect_ratio": "16:9"
    }
  }'
Successful response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
Save the taskId; you need it to poll for the final result.

Poll for result

curl -X GET "https://api.apixo.ai/api/v1/statusTask/midjourney?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
Processing response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
Success response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/img1.png\",\"https://file.apixo.ai/img2.png\",\"https://file.apixo.ai/img3.png\",\"https://file.apixo.ai/img4.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
Failed response:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "PromptInvalid",
    "failMsg": "Prompt is invalid or rejected by provider",
    "createTime": 1767965610929,
    "completeTime": 1767965620132,
    "costTime": 9203
  }
}
Parse resultJson after state becomes success:
const payload = JSON.parse(data.resultJson);
const imageUrls = payload.resultUrls;

Request body

Text-to-image

{
  "request_type": "async",
  "input": {
    "mode": "text-to-image",
    "prompt": "a quiet library inside a glass greenhouse, soft morning light",
    "version": "7",
    "speed": "fast",
    "aspect_ratio": "16:9",
    "stylization": 100,
    "variety": 10,
    "weirdness": 0
  }
}

Image-to-image

{
  "request_type": "async",
  "input": {
    "mode": "image-to-image",
    "prompt": "a dog lying in a bright park with green grass and trees",
    "image_urls": [
      "https://example.com/dog-at-home.jpg"
    ],
    "version": "7",
    "speed": "fast",
    "aspect_ratio": "4:3"
  }
}

Upload-paint

Use upload-paint when you want to edit a specific region. If mask, canvas, and imgPos are omitted on compatible routes, the backend can auto-fill a full-image edit region from image_urls[0].
{
  "request_type": "async",
  "input": {
    "mode": "upload-paint",
    "prompt": "add a modern espresso machine on the counter",
    "image_urls": [
      "https://example.com/cafe.jpg"
    ],
    "version": "7",
    "speed": "fast",
    "mask": {
      "areas": [
        {
          "width": 1024,
          "height": 1024,
          "points": [320, 420, 700, 420, 700, 760, 320, 760]
        }
      ]
    },
    "canvas": {
      "width": 1024,
      "height": 1024
    },
    "imgPos": {
      "width": 1024,
      "height": 1024,
      "x": 0,
      "y": 0
    }
  }
}

Vary

{
  "request_type": "async",
  "input": {
    "mode": "vary",
    "taskId": "task_previous_midjourney",
    "imageIndex": 0,
    "type": 1,
    "remixPrompt": "more dramatic lighting and richer color contrast"
  }
}

Upscale

{
  "request_type": "async",
  "input": {
    "mode": "upscale",
    "taskId": "task_previous_midjourney",
    "imageIndex": 2,
    "type": 0
  }
}

Parameters

request_type
string
default:"async"
required
Result delivery mode. Use async for polling with statusTask, or callback for webhook delivery.
callback_url
string
Required when request_type is callback. Must be a public HTTPS URL that can receive the final task payload. See Webhooks.
input
object
required
Midjourney input parameters.

Response format

Submit task response

POST /generateTask/midjourney returns a task ID when the task is accepted:
code
integer
API status code. 200 means the task was accepted.
message
string
Human-readable status message.
data.taskId
string
Unique APIXO task identifier used with the status endpoint.

Status response fields

taskId
string
Unique APIXO task identifier.
state
string
Current task state: pending, processing, success, or failed.
resultJson
string
JSON string containing the generated image URLs. Present when state is success.
failCode
string
Machine-readable failure code. Present when state is failed.
failMsg
string
Human-readable failure message. Present when state is failed.
createTime
integer
Task creation timestamp in Unix milliseconds.
completeTime
integer
Task completion timestamp in Unix milliseconds. Present after completion.
costTime
integer
Processing duration in milliseconds. Present after completion.

Webhook callback mode

Use callback mode when your backend should receive the final result automatically instead of polling.
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": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "text-to-image",
      "prompt": "a premium watch on dark stone, macro photography, soft reflections",
      "version": "7",
      "speed": "fast",
      "aspect_ratio": "1:1"
    }
  }'
See Webhooks for delivery requirements and retry behavior.

Billing

Midjourney is billed per use. The selected speed determines the unit price. Public pricing currently lists fast and turbo.
SpeedAPIXO priceMarket comparison
fast$0.15 / use$0.30 / use
turbo$0.25 / use$0.50 / use
For current route and market comparison pricing, see Pricing.

Latency and polling

Actual latency may vary by prompt complexity, mode, selected route, and current queue load.
Mode or speedTypical generation timeRecommended first pollPoll interval
turbo generation15s-25s20s after task creation3s-5s
fast generation30s-45s20s after task creation3s-5s
vary or upscale15s-60s15s after task creation3s-5s
For high-concurrency production workloads, use callback mode to avoid frequent polling.
Rate limits and concurrency can vary by account, API key, and route. If you receive 429, slow down requests and retry with backoff. For account-level details, see System APIs.

Errors and troubleshooting

HTTP errors

CodeMeaningWhat to do
400Invalid request body, mode, parameter, prompt, or image URLFix the request before retrying
401Missing or invalid API keyCheck the Authorization header
402Insufficient balance or quotaAdd balance or switch account/key
403Key or route cannot access the modelCheck permissions and route strategy
429Rate limit or concurrency limit reachedRetry with exponential backoff
500Server errorRetry with backoff
502Upstream provider errorRetry with backoff
504Upstream timeoutRetry or use callback mode for long-running jobs

Task failure codes

Fail codeMeaningWhat to do
PromptInvalidPrompt is invalid or rejected by the providerRewrite the prompt and remove unsafe or malformed content
MissingParameterRequired request parameters are missingCheck mode, prompt, speed, image_urls, taskId, and imageIndex
SensitiveContentDetectedInput or output was flagged by safety checksChange the prompt or source image
InputOutputSensitiveContentDetectedThe input or output was flagged as sensitiveTry different inputs
Upload errorImage upload or image size validation failedUse a public direct image URL and keep image files within supported limits
Website TimeOutMidJourney official website did not respond after multiple attemptsRetry later or use callback mode
Task TimeOutThe upstream task became outdated or timed outRetry the generation
RateLimitExceededUpstream or APIXO rate limit was reachedRetry with exponential backoff

Common fixes

SymptomFix
Invalid mode typeUse one of text-to-image, image-to-image, upload-paint, vary, or upscale.
Parameter is ignoredUse stable API field names: aspect_ratio, variety, stylization, and weirdness.
Prompt unexpectedly loses flagsMove Midjourney flags out of prompt; text after the first -- is stripped by the backend.
taskId not found for vary or upscaleUse the APIXO task ID from a previous Midjourney result, not the upstream provider task ID.
Upload-paint fails to read image sizeUse a public, directly fetchable source image URL. The backend reads image_urls[0] to fill default canvas and mask values.
relaxed fails billing or routingUse fast or turbo unless your account has explicit relaxed pricing enabled.
See Error Codes for the full error reference.