Skip to main content

Overview

Midjourney is an async image model for high-quality diffusion generation, source-image-guided generation, region editing, variation, upscaling, reroll, and draft enhancement. 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, image-edit, vary, upscale, reroll, enhance
Prompt lengthNon-empty. Route limits are up to 2000 characters or up to 7500 UTF-8 bytes; keep prompts under 2000 characters for portable requests.
Reference imagestext-to-image supports up to 20 image_urls as image prompts. image-to-image requires at least one image reference field and still uses diffusion. image-edit requires exactly 1 source image for the edit base.
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, draft; relaxed is deprecated by the official provider. To maintain compatibility, we still accept this value, but it will be converted to fast for execution and billing. draft belongs to the diffusion family, so it is available for text-to-image and image-to-image when version=7.
Result countUsually 4 images for generation and variation, usually 1 image for upscale and enhance

Workflow categories

CategoryModesDescription
Direct generationtext-to-image, image-to-image, image-editSubmit a new task directly. image-to-image is the diffusion route with at least one required image reference. image-edit is the region editing workflow.
Secondary editingvary, upscale, reroll, enhanceOperate on a previous Midjourney task result. reroll uses taskId. vary, upscale, and enhance use taskId plus imageIndex. enhance is only available for draft results.
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",
      "image_urls": [
        "https://example.com/scene-reference.jpg"
      ],
      "sref_urls": [
        {
          "url": "https://example.com/style-reference.jpg",
          "weight": 2
        }
      ],
      "iw": 1.5,
      "sw": 500,
      "sv": 6,
      "negative_prompt": "text, watermark"
    }
  }'
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\"]}",
    "supported_actions": [
      {
        "mode": "reroll"
      },
      {
        "mode": "vary",
        "imageIndex_options": [0, 1, 2, 3],
        "type_options": [0, 1]
      },
      {
        "mode": "upscale",
        "imageIndex_options": [0, 1, 2, 3],
        "type_options": [0, 1, 2, 3]
      },
      {
        "mode": "image-edit",
        "imageIndex_options": [0, 1, 2, 3]
      },
      {
        "mode": "enhance",
        "imageIndex_options": [0, 1, 2, 3]
      }
    ],
    "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;
Use data.supported_actions directly when you want to present follow-up actions to users. It is returned at the same level as resultJson and is only present when follow-up operations are available. The follow-up action set depends on the source task mode:
Source modeFollow-up modes
text-to-imagereroll, vary, upscale, image-edit, enhance
image-to-imagereroll, vary, upscale, image-edit, enhance
image-editimage-edit, upscale
varyreroll, vary, upscale, image-edit
upscalevary, image-edit
rerollreroll, vary, upscale, image-edit, enhance
enhancevary, upscale, image-edit
enhance is only returned for successful v7 + draft generation-family results. Follow-up actions that continue from a specific image can include imageIndex_options so clients can ask the user which image to continue from.

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",
    "image_urls": [
      "https://example.com/scene-reference.jpg"
    ],
    "sref_urls": [
      {
        "url": "https://example.com/style-reference.jpg",
        "weight": 2
      }
    ],
    "iw": 1.5,
    "sw": 500,
    "sv": 6,
    "negative_prompt": "text, watermark",
    "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"
  }
}

Image-edit

Use image-edit 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": "image-edit",
    "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
  }
}

Reroll

{
  "request_type": "async",
  "input": {
    "mode": "reroll",
    "taskId": "task_previous_midjourney"
  }
}

Enhance

{
  "request_type": "async",
  "input": {
    "mode": "enhance",
    "taskId": "task_previous_midjourney",
    "imageIndex": 1
  }
}

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.
text-to-image and image-to-image share the diffusion parameter family. image-to-image requires at least one image reference across image_urls, sref_urls, cref_urls, or oref_urls, while text-to-image treats image_urls as optional image prompts. image-edit is a separate region-editing workflow and uses mask, canvas, imgPos, and optional remixPrompt.

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.
supported_actions
array
Optional follow-up actions for successful results. This field is returned at the same level as resultJson in data.
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 mode and speed determine the unit price. The current public pricing is easiest to understand in two families:
CategoryModeAPIXO priceNotes
Direct generationtext-to-image$0.10 / use (draft), $0.20 / use (fast), $0.40 / use (turbo)Diffusion generation. v8.1 with is_hd=true and fast is $0.30 / use.
Direct generationimage-to-imageSame as text-to-imageUses the same diffusion route as text-to-image, but requires at least one image reference input.
Direct generationimage-edit$0.30 / use (fast), $0.60 / use (turbo)Region editing workflow.
Secondary editingvary$0.30 / useRequires a previous taskId and imageIndex.
Secondary editingupscale$0.30 / useRequires a previous taskId and imageIndex.
Secondary editingrerollSame as the source task priceRe-runs the previous successful task with the same configuration.
Secondary editingenhanceSee PricingDraft-only enhancement workflow. Requires a previous taskId and imageIndex.
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, upscale, or enhance15s-60s15s after task creation3s-5s
rerollSimilar to the original generation speed20s 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, image-edit, vary, upscale, reroll, or enhance.
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, upscale, reroll, or enhanceUse the APIXO task ID from a previous Midjourney result, not the upstream provider task ID.
Image-edit 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 does not match expected execution speed or billingrelaxed is accepted for compatibility, but APIXO converts it to fast for execution and billing.
draft is rejecteddraft is only supported in the diffusion family (text-to-image and image-to-image) when version=7.
enhance is rejectedenhance only works for successful Midjourney draft results.
See Error Codes for the full error reference.