Image / Midjourney

MJ Image / Video Generation ()## Overview

MJ endpoint provide image, image, Image-to-Video, video etc. Capability, task ()Model:endpoint after returnjobId, query endpointPollingTask Status.

will/aigc/mj endpointas endpoint (/mj/v1/tob/*), Path.localized example text/aigc/mj endpointlocalized example text.

Base URL: https://mm-internal-cn.leonecloud.com


Authentication

with endpoint in Request in API Key:```
Authorization: Bearer {YOUR_API_KEY}


---

## (endpoint)

 with endpoint (image / video) return task:| field | Type | Description |
|------|------|------|
| jobId | string | Task ID, after query or|
| comment | string | Task Status, localized example text「Task Status」localized example text|
| reason | string | Failure(onlytaskFailurereturned when applicable, )|
| text | string | Prompt (imagetaskreturn )|
| urls | string[] | imageURL list (imagetask)|
| videoUrls | string[] | videoURL list (videotask)|
| cost | number |, task complete after|
| createdAt | string | Created Time (query endpoint return )|
| finishedAt | string | complete when ( query endpoint return )|

> Create Taskwhen`comment` as`JobStatusCreated`, `urls` / `videoUrls` as,`cost` as 0.localized example text「Query Tasklocalized example text」endpointlocalized example text.

**create SuccessResponse Example**

```json

{
"jobId": "task_20260529150000_abc12345",
"comment": "JobStatusCreated",
"text": "can in,",
"urls": [],
"cost": 0
}


---

## Errorlocalized example text```json
{
 "code": 400,
 "message": "Invalid_Argument",
 "reason": "Request Parametersno:..."
}
fieldTypeDescription
codeintError Codes
messagestringErrorlocalized example text
reasonstringFailurelocalized example text

Error Codes「Error Codes」localized example text.


endpointlocalized example text| localized example text| endpoint | Method | Path | |------|------|------|------| | Image Generation | image| POST | /api/v2/open/mj/v1/tob/diffusion | | Image Generation | localized example text| POST | /api/v2/open/mj/v1/tob/variation | | Image Generation | height| POST | /api/v2/open/mj/v1/tob/upscale | | Image Generation | execute| POST | /api/v2/open/mj/v1/tob/reroll | | Image Generation | localized example text| POST | /api/v2/open/mj/v1/tob/pan | | Image Generation | image| POST | /api/v2/open/mj/v1/tob/outpaint | | Image Generation | repainting| POST | /api/v2/open/mj/v1/tob/inpaint | | Image Generation | localized example text| POST | /api/v2/open/mj/v1/tob/remix | | Image Generation | localized example text| POST | /api/v2/open/mj/v1/tob/edit | | Image Generation | height| POST | /api/v2/open/mj/v1/tob/upload-paint | | Image Generation | localized example text| POST | /api/v2/open/mj/v1/tob/retexture | | Image Generation | localized example text| POST | /api/v2/open/mj/v1/tob/remove-background | | Image Generation | localized example text| POST | /api/v2/open/mj/v1/tob/enhance | | Video Generation | Image-to-Video | POST | /api/v2/open/mj/v1/tob/video-diffusion | | Video Generation | videolocalized example text| POST | /api/v2/open/mj/v1/tob/extend-video | | Video Generation | videoheight| POST | /api/v2/open/mj/v1/tob/video-upscale | | taskquery| Query Tasklocalized example text| GET | /api/v2/open/mj/v1/tob/job/{jobId} |


##, Image Generationendpoint### 1.1 imagePOST /api/v2/open/mj/v1/tob/diffusion

image endpoint.Prompt, Parameter, Reference image URLtext field( and Prompt, can in in image and--ar, --v etc. Parameter).localized example texttext in image when Image-to-Image, Text-to-Image.

Request Parameters

ParameterTypeRequiredDescription
textstringYesPrompt, supported, image URL, Parameter
callbackstringNoCallback URL

Request Example

{
 "text": "can in, --ar 16:9 --v 7",
 "callback": "https://your-domain.com/callback"
}

use Scenariotext field, Scenario ([] Optional, Request in Not required):| Scenario | text fieldFormat | Description | |------|--------------|------| | image| localized example text[--Parameter] | onlyimage| | image+ localized example text| imageURL localized example text[--Parameter] | reference images image, image| | image| imageURL1 imageURL2 [--Parameter] | multiple imagesimage and ( no )| | image+ localized example text| imageURL1 imageURL2 localized example text[--Parameter] | multiple imagesReference imagelocalized example text| | characterreference| --cref imageURL | in image in character,,| | reference| --sref imageURL | Reference image (,, )| | localized example text| --oref imageURL | will Reference image in the character or Scenario (only v7)|

text in canhttp:// / https:// imageImage-to-Image; image can.image aslocalized example text, no Reference image, Pricing (task, image), only.

Parameter

Parameter intext in, and Prompt, image,--ar 16:9 --v 7 --cref https://.../face.jpg --cw 80.

ParameterDescriptionvalue range
--arAspect ratiolocalized example text16:9, 1:1, 2:3
--vModellocalized example text6 / 6.1 / 7 / 8.1 / 8.2
--nijiModel ( and--v )6 / 7
--iwimage, Reference image0-3 (Niji 7 as 0-2), default 1
--crefcharacterReference image URLsupported v6 / v6.1 / Niji 6
--cwcharacterreference0-100, default 100
--srefReference image URL ( can )supported image Model
--swreference0-1000, default 100
--svlocalized example text1-4 (v7 supported 1-6), default 4
--orefimage URL (only 1 images )only v7
--owlocalized example text1-1000, default 100
Parameter,; ParameterFormatError when task willJobStatusBadPrompt / JobStatusInvalidParameter Statusreturn,.

(--v Parameter)

Modelintext in--v Parameter, in Prompt can, can and--ar, --sref etc. Parameter.not--v when use default.

localized example textlocalized example textDescription
--v 6 / --v 6.1v6 / v6.1localized example text
--v 7v7supported (--oref), image
--v 8.1v8.1, Prompt, supported 2K height (--hd), --q onlysupported1 / 4
--v 8.2v8.2and v8.1 Capability,--q supported1 / 2 / 3 / 4

use:

{
 "text": "young elven hunter with moss-woven armor, soft forest light --ar 2:3 --raw --v 8.2 --hd",
 "callback": "https://your-domain.com/callback"
}
- in--v after,--v 8.2; localized example text--v default.
- v8.1 and v8.2:v8.1 localized example text--q (image quality)only supported1 and4, v8.2 as1 / 2 / 3 / 4 (4 as height quality).

Model (--niji Parameter)

Niji and, in character, and.localized example text--niji,and--v localized example text (when when as, recommended).

localized example textlocalized example textDescription
--niji 6Niji 6supported character reference (--cref / --cw), --q localized example text0.25 / 0.5 / 1
--niji 7Niji 7characterand character, can in and height

use:

{
 "text": ",,, --niji 7 --ar 2:3 --stylize 300",
 "callback": "https://your-domain.com/callback"
}

and v Parameter:

ParameterNiji 6Niji 7
--q quality0.25 / 0.5 / 1supported
--cref / --cw characterreferencesupported,--cw 0-100supported
--sv localized example text1 / 2 / 3 / 44 / 5 / 6
--iw image0-30-2
--hd 2Ksupportedsupported
--draft imagesupportedsupported
--oref / --expsupportedsupported
- Niji and vlocalized example text, ().
- --sref (reference ),--sw, --ar, --raw, --stylize, --chaos, --seed, --no and Parameter in Niji can use.
- Niji (,, etc. ) and v, task and.

v8 (v8.1 / v8.2)with Parameter

v8.1 and v8.2 in v7 ParameterCapability, intext in:ParameterDescriptionvalue rangelocalized example text
--hd2K height, output height Resolution, task 4 images height imageno1.5× localized example text
--qimage quality,4 as height qualityv8.1:1 / 4; v8.2:1 / 2 / 3 / 4, default 1localized example text
--raw, defaultnolocalized example text
--stylizelocalized example text0-1000, default 100localized example text
--expParameter,0-100, default 0localized example text
--draft24 images 0.5K image,noas 1 (v8 image v7 0.5× )
- v8 height image--hd ( 2K), use「height」endpoint, task 4 images height image.
- --q and reference (--sref / Moodboard)localized example text.
- v8 v7--sref reference and Moodboard, with can.
- v8 localized example text「image」task (,, etc. ) and v7.

()

intext in Parameter,.not when defaultlocalized example text.

Parameterlocalized example textlocalized example textDescription
--fast(default)1×default, Parameter when as
--turbolocalized example text2×image,
--draftimage0.5× (only --v 7); v8 can use--draft (24 images ), as 1 ().Niji supported image
--relaxlocalized example text1×( no )
- Parameter and--ar, --v etc. intext in, can and Parameter,... --ar 16:9 --v 7 --turbo.
- (,, etc. ), task.
- as, as.:"text": "--ar 16:9 --v 7 --turbo" (, 2× )#### Response Example
{
 "jobId": "task_20260529150000_abc12345",
 "comment": "JobStatusCreated",
 "text": "can in, --ar 16:9 --v 7",
 "urls": [],
 "cost": 0
}

1.2 (Variation)**POST** /api/v2/open/mj/v1/tob/variation

image in the images,.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID
imageNointYesimage (1-4)
typeintYes:0 /1 localized example text
remixPromptstringNoPrompt
callbackstringNoCallback URL

Request Example

{
 "jobId": "task_20260529150000_abc12345",
 "imageNo": 1,
 "type": 1,
 "remixPrompt": "Scenario"
}

1.3 height (Upscale)**POST** /api/v2/open/mj/v1/tob/upscale

image height.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID
imageNointYesimage (1-4)
typeintYes:0 /1 /2 v5_2x / 3 v5_4x
callbackstringNoCallback URL

Request Example

{
 "jobId": "task_20260529150000_abc12345",
 "imageNo": 1,
 "type": 0
}

1.4 execute (Reroll)**POST** /api/v2/open/mj/v1/tob/reroll

task Parameterimage.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID
callbackstringNoCallback URL

Request Example

{
 "jobId": "task_20260529150000_abc12345"
}

1.5 (Pan)**POST** /api/v2/open/mj/v1/tob/pan

and.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID
imageNointYesimage (1-4)
directionintYes:0 /1 /2 /3 localized example text
scalenumberYes(1.1-3.0)
remixPromptstringNoPrompt
callbackstringNoCallback URL

Request Example

{
 "jobId": "task_20260529150000_abc12345",
 "imageNo": 1,
 "direction": 1,
 "scale": 1.5,
 "remixPrompt": "localized example text"
}

1.6 image (Outpaint)**POST** /api/v2/open/mj/v1/tob/outpaint

in image.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID
imageNointYesimage (1-4)
scalenumberYes(1.1-2.0)
remixPromptstringNoimage Prompt
callbackstringNoCallback URL

Request Example

{
 "jobId": "task_20260529150000_abc12345",
 "imageNo": 1,
 "scale": 2.0
}

1.7 repainting (Inpaint)**POST** /api/v2/open/mj/v1/tob/inpaint

Mask repainting.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID
imageNointYesimage (1-4)
maskobjectYesMask(areas, orurl Maskimage, )
remixPromptstringNorepainting
callbackstringNoCallback URL
mask localized example text (areas andurl ):fieldTypeDescription
areasarraylist,width, height andpoints (,x1,y1,x2,y2,... )
urlstringMaskimage URL (Mask, as repainting )

Request Example

Method:```json
{
"jobId": "task_20260529150000_abc12345",
"imageNo": 1,
"mask": {
"areas": [
{
"width": 100,
"height": 100,
"points": [10, 10, 10, 100, 100, 100, 100, 10]
}
]
},
"remixPrompt": "localized example text"
}


Maskimage Method:```json
{
 "jobId": "task_20260529150000_abc12345",
 "imageNo": 1,
 "mask": { "url": "https://example.com/mask.png" },
 "remixPrompt": "localized example text"
}

1.8 (Remix)**POST** /api/v2/open/mj/v1/tob/remix

Promptimage.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID
imageNointYesimage (1-4)
remixPromptstringYesPrompt
modeintNo:0 (default) /1 localized example text
callbackstringNoCallback URL

Request Example

{
 "jobId": "task_20260529150000_abc12345",
 "imageNo": 1,
 "remixPrompt": "as",
 "mode": 0
}

1.9 (Edit)**POST** /api/v2/open/mj/v1/tob/edit

in and image Locationimage.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID
imageNointYesimage (1-4)
canvasobjectYesdimensions
imgPosobjectYesimage Location
remixPromptstringYeslocalized example text
maskobjectNoimage repainting
callbackstringNoCallback URL

canvas localized example text:

fieldTypeDescription
widthintwidth ()
heightintheight ()
imgPos localized example text (image in in the Location and dimensions ):fieldTypeDescription
widthintimage width ()
heightintimage height ()
xint(, )
yint(, )

Request Example

{
 "jobId": "task_20260529150000_abc12345",
 "imageNo": 1,
 "canvas": { "width": 1024, "height": 1024 },
 "imgPos": { "width": 1024, "height": 768, "x": 0, "y": 0 },
 "remixPrompt": "in"
}

1.10 height (Upload Paint)**POST** /api/v2/open/mj/v1/tob/upload-paint

image URL and Mask,, image Location ( no task).

Request Parameters

ParameterTypeRequiredDescription
imgUrlstringYesimage URL
maskobjectYesMask(「repainting」mask)
canvasobjectYesdimensions (「localized example text」canvas)
imgPosobjectYesimage Location (「localized example text」imgPos)
remixPromptstringYeslocalized example text
callbackstringNoCallback URL

Request Example

{
 "imgUrl": "https://example.com/source.jpg",
 "mask": { "url": "https://example.com/mask.png" },
 "canvas": { "width": 1024, "height": 1024 },
 "imgPos": { "width": 1024, "height": 1024, "x": 0, "y": 0 },
 "remixPrompt": "as"
}

1.11 (Retexture)**POST** /api/v2/open/mj/v1/tob/retexture

image, /.can inremixPrompt in--sref image URL localized example text.use v6.1 and Model.

Request Parameters

ParameterTypeRequiredDescription
imgUrlstringYesimage URL
remixPromptstringYeslocalized example text
callbackstringNoCallback URL

Request Example

{
 "imgUrl": "https://example.com/source.jpg",
 "remixPrompt": "as"
}

1.12 (Remove Background)**POST** /api/v2/open/mj/v1/tob/remove-background

image, output image.

Request Parameters

ParameterTypeRequiredDescription
imgUrlstringYesimage URL
callbackstringNoCallback URL

Request Example

{
 "imgUrl": "https://example.com/source.jpg"
}

1.13 (Enhance)**POST** /api/v2/open/mj/v1/tob/enhance

image.onlylocalized example textimage (--draft) image.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID
imageNointYesimage (1-4)
callbackstringNoCallback URL

Request Example

{
 "jobId": "task_20260529150000_abc12345",
 "imageNo": 1
}

##, Video Generationendpoint### 2.1 Image-to-Video (Video Diffusion)

POST /api/v2/open/mj/v1/tob/video-diffusion

Image Generationvideo.supported image,:

-localized example text:imagetaskjobId + imageNo (1-4), image as video first frame;
-localized example text:inprompt in provide image.

Request Parameters

ParameterTypeRequiredDescription
jobIdstringConditionimageTask ID (, andprompt in the image)
imageNointNoimage1-4 (localized example textjobId use, images image as first frame )
promptstringConditionPrompt; in in image
videoTypeintNovideoResolution:0 as 480p (default) /1 as 720p
callbackstringNoCallback URL
Duration as 5 seconds.videofirst frame image,:| image| videolocalized example text| Resolutionlocalized example text|
|----------|----------|-----------|
| 1:1 | 1:1 | 624×624 |
| 4:3 | 77:58 | 720×544 |
| 2:3 | 2:3 | 512×768 |
| 16:9 | 91:51 | 832×464 |
720p (videoType=1)as 480p 3.2, as.

Request Example

(image):```json
{
"jobId": "task_20260529150000_abc12345",
"imageNo": 1,
"prompt": "in the",
"videoType": 1
}


(prompt in image):```json
{
 "prompt": "https://example.com/source.jpg in the",
 "videoType": 0
}

Response Example

{
 "jobId": "task_20260529160000_def67890",
 "comment": "JobStatusCreated",
 "videoUrls": [],
 "cost": 0
}

2.2 video(Extend Video)**POST** /api/v2/open/mj/v1/tob/extend-video

in video.4 seconds, up to can 4 ( maximum 21 seconds:5+ 4×4).

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesvideoTask ID
videoNointYesvideolocalized example text
promptstringYeslocalized example text
callbackstringNoCallback URL

Request Example

{
 "jobId": "task_20260529160000_def67890",
 "videoNo": 0,
 "prompt": "first"
}

2.3 videoheight (Video Upscale)**POST** /api/v2/open/mj/v1/tob/video-upscale

video height, output 1080P video (videoDuration).

Request Parameters

ParameterTypeRequiredDescription
jobIdstringYesvideoTask ID
videoNointYesvideolocalized example text
callbackstringNoCallback URL

Request Example

{
 "jobId": "task_20260529160000_def67890",
 "videoNo": 0
}

##, task query endpoint### 3.1 Query Tasklocalized example textGET /api/v2/open/mj/v1/tob/job/{jobId}

query task Statusand result, Polling.

Path Parameters

ParameterTypeRequiredDescription
jobIdstringYesTask ID

Response Example

processing

{
 "jobId": "task_20260529150000_abc12345",
 "comment": "JobStatusRunning",
 "text": "can in,",
 "urls": [],
 "cost": 0,
 "createdAt": "2026-05-29T15:00:00+08:00"
}

Success (image)

{
 "jobId": "task_20260529150000_abc12345",
 "comment": "JobStatusSuccess",
 "text": "can in,",
 "urls": [
 "https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/2026/05/29/output_001.png"
 ],
 "cost": 0.6,
 "createdAt": "2026-05-29T15:00:00+08:00",
 "finishedAt": "2026-05-29T15:01:30+08:00"
}

Success (video)

{
 "jobId": "task_20260529160000_def67890",
 "comment": "JobStatusSuccess",
 "videoUrls": [
 "https://fc-gw-sh.oss-accelerate.aliyuncs.com/videos/2026/05/29/output.mp4"
 ],
 "cost": 1.2,
 "createdAt": "2026-05-29T16:00:00+08:00",
 "finishedAt": "2026-05-29T16:03:30+08:00"
}

Failure

{
 "jobId": "task_20260529150000_abc12345",
 "comment": "JobStatusFail",
 "reason": "Failure",
 "cost": 0,
 "createdAt": "2026-05-29T15:00:00+08:00",
 "finishedAt": "2026-05-29T15:00:40+08:00"
}
taskFailurewhencomment as FailureStatus,reason fieldafter Failure, the frozen amount is automatically returned.

Task Status

endpoint returncomment fieldand query endpointstatus fielduse Status:Statuslocalized example textDescription
JobStatusCreatedcreate
JobStatusQueuedqueued
JobStatusRunningexecute in
JobStatusSuccessSuccess
JobStatusFailFailure (not Error)
JobStatusErrorexecute
JobStatusRejectimagenot
JobStatusTextRejectnot
JobStatusBadPromptPromptFormatError
JobStatusInvalidParameterPromptFormatError, localized example text
JobStatusTimeouttaskFailure (when )
JobStatusRequestTimeouttaskFailure ( when )
JobStatusInvalidImagePromptLinkno image
JobStatusMaxConcurrentLimitedwhen task
JobStatusCreditNotEnoughtasklocalized example text
JobStatusCanceledTask cancelled
JobStatusImagePromptDeniedimage prompt localized example text
JobStatusDuplicateImagein Image

Callback Notification

Create Taskwhen providecallback, taskcomplete (Success or Failure) after the system will POST Request, Request Body as task ( and「Query Tasklocalized example text」).

Headers

Content-Type: application/json

Body localized example text

{
 "jobId": "task_20260529150000_abc12345",
 "comment": "JobStatusSuccess",
 "urls": ["https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/output_001.png"],
 "cost": 0.6,
 "createdAt": "2026-05-29T15:00:00+08:00",
 "finishedAt": "2026-05-29T15:01:30+08:00"
}

return HTTP 200 Success.


Error Codes

codemessageDescription
400Invalid_ArgumentRequest Parametersno / Task not found
402Account_Fee_Not_EnoughInsufficient balance
500Internal_Server_ErrorInternal server error

Best Practices

1. taskPolling Strategy

endpoint as task,「Query Tasklocalized example text」 (GET /job/{jobId})Pollinglocalized example text.recommendedPolling:

  • First 30 seconds:query every 3 seconds
  • 30 seconds~ 2 minutes:query every 5 seconds
  • After 2 minutes:query every 10 seconds

localized example textcomment asJobStatusSuccess whenurls / videoUrls; as FailureStatus when Polling.

2. Processing Time Reference

  • image /:Usually 30 seconds~ 2 minutes
  • Image-to-Video:Usually 1 ~ 5 minutes
  • video/ video height:Usually 1~ 3 minutes

3. Balance Management

  • Create Taskwhen will (), Insufficient balance will return402 Account_Fee_Not_Enough.
  • taskSuccessafter in,cost fieldlocalized example text.
  • taskFailureafter the frozen amount is automatically returned.

4. - / / / image / repainting / / / etc. endpointvalid taskjobId, andimageNo image. - video/ video height Success videotaskjobId andvideoNo.

Updated 2026-11-24