MaaS-MJ
I. Request Protocol
https
Header
| Parameter Name | Type | Description |
|---|---|---|
| anthorization | string | Authentication |
2. Dosage
2.1 Billing Standards
All interfaces adopt two-stage billing:
| Phase | timing | Description |
|---|---|---|
| Phase 1 | When the task is created | Write to MongoDB, cost= 0, success= falseplaceholder |
| Phase II | When the task is completed | Triggered by polling (GET /tob/job/{jobId}) or Youchuan callback, it updates costto the actual expense and reports it for billing |
Billing is based on the cost.fastCostreturned by Youchuan (points consumed in fast mode). The --draftmode costs 0.5 times that of the standard mode.
2.2 Billing Items
| Trigger Condition | Billing Item (chargeItemCode) | Dosage Type (type) |
|---|---|---|
| All image interfaces succeeded | unit |
CREDIT |
3. Interface Documentation
All interfaces are required to carry authentication information, which will be processed uniformly by the gateway.
All POST interfaces are asynchronous tasks, and a
jobIdwill be returned upon successful creation, you can poll the status via the query interface.
3.1 Text-to-Image
No charge (during task creation phase), and billing will be based on actual consumption after the task is completed.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| text | string |
Yes | Prompt. Supports plain text, embedded image URLs (image-to-image), and MJ parameters such as --ar 16:9, --draft, --sref [URL], --oref [URL], etc. |
Response Parameters
| field | Type | Description |
|---|---|---|
| id | string | Task ID, used for subsequent polling |
| status | integer | Task Status: 1= In Progress, 2= Succeeded, 3= Failed |
| comment | string | Status Description |
| text | string | Original Prompt |
| urls | array\\ |
List of generated image URLs (4 items), which is an empty array while the task is in progress |
| seed | integer | The random seed used for this generation |
| cost | object | Fee Information (to be filled in upon task completion) |
| cost.fastCost | number | Points consumed in Fast Mode |
| cost.feeCost | number | Fiat Fees |
| cost.relaxCost | number | Slow mode consumes points |
Request Example
Response Example
{
"id": "6a13efcec6b99f3fdfec4914",
"status": 2,
"comment": "Success",
"text": "A panda wearing a hat, watercolor style --ar 1:1",
"urls": [
"https://openapi-youchuan.oss-cn-shanghai.aliyuncs.com/xxx_0.png",
"https://openapi-youchuan.oss-cn-shanghai.aliyuncs.com/xxx_1.png",
"https://openapi-youchuan.oss-cn-shanghai.aliyuncs.com/xxx_2.png",
"https://openapi-youchuan.oss-cn-shanghai.aliyuncs.com/xxx_3.png"
],
"seed": 2464799781,
"cost": {
"fastCost": 1.0,
"feeCost": 60.0,
"relaxCost": 0.0
}
}
Note:
urlsreturns 4 images, corresponding toimageNo0-3; when performing secondary editing later, useimageNoto specify which image to operate on.
3.2 Query Task Status
No charge. Meanwhile, the second-stage billing will be triggered (if the task has just been completed).
Request URL
Path Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Task ID |
Response Parameters
Same as the response parameters in Section 3.1.
Task Status Description
| status value | Meaning |
|---|---|
| 1 | In progress |
| 2 | Success |
| 3 | Failure |
3.3 Region Inpainting
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Original Task ID |
| imageNo | integer | Yes | Original image number, with a value range of 0-3 |
| mask | object | Yes | Mask definition, supports areas (coordinate regions) or url (mask image address) |
| mask.areas | array | No | List of Polygon Regions |
| mask.areas[].width | integer | Yes | Image width, ranging from 500 to 4096 |
| mask.areas[].height | integer | Yes | Image height, ranging from 500 to 4096 |
| mask.areas[].points | array\\ |
Yes | Polygon vertex coordinates, format:[x1, y1, x2, y2,. ..], arranged in clockwise order |
| mask.url | string | No | Mask image address (black and white image, white indicates the redrawing area) |
| remixPrompt | string | No | Prompt for describing the redraw area |
Request Example
{
"jobId": "6a13efcec6b99f3fdfec4914",
"imageNo": 0,
"mask": {
"areas": [{
"width": 1024,
"height": 1024,
"points": [200, 200, 200, 800, 800, 800, 800, 200]
}]
},
"remixPrompt": "Add a red hat"
}
3.4 Upscale (High-Definition Upscaling)
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Original Task ID |
| imageNo | integer | Yes | Original image number, with a value range of 0-3 |
| type | integer | Yes | Zoom Mode: 0= Standard, 1= Creative, 2= v5_2x, 3= v5_4x |
Request Example
3.5 Variation
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Original Task ID |
| imageNo | integer | Yes | Original image number, with a value range of 0-3 |
| type | integer | Yes | Degree of change: 0 = slight change, 1 = intense change |
| remixPrompt | string | No | Refine the prompt to adjust the direction based on the changes |
Request Example
{
"jobId": "6a13efcec6b99f3fdfec4914",
"imageNo": 1,
"type": 0,
"remixPrompt": "Make the hat blue"
}
3.6 Reroll the Task
Regenerating a new batch of images with the same parameters is equivalent to re-rolling the gacha.
Note: This interface does not support passing in
callbackalone; the callback URL is inherited from the original task.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Original Task ID |
Request Example
3.7 Pan (Panning)
Extend and expand the content of the frame in the specified direction.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Original Task ID |
| imageNo | integer | Yes | Original image number, with a value range of 0-3 |
| direction | integer | Yes | Extension direction: 0 = Down, 1 = Right, 2 = Up, 3 = Left |
| scale | float | Yes | Scaling ratio, value range: 1.1-3.0 |
| remixPrompt | string | No | Outpainting Prompt |
Request Example
3.8 Outpainting
Expand the image equally in all directions.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Original Task ID |
| imageNo | integer | Yes | Original image number, with a value ranging from 0 to 3 |
| scale | float | Yes | Zoom ratio, value range: 1.1-2.0 |
| remixPrompt | string | No | Outpainting Area Prompt |
Request Example
3.9 Remix
While retaining the composition of the original image, use new prompts to modify the content of the picture.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Original Task ID |
| imageNo | integer | Yes | Original image number, with a value ranging from 0 to 3 |
| remixPrompt | string | Yes | New Prompt |
| mode | integer | No | Remodeling Mode: 0= Intense (Default), 1= Subtle |
Request Example
{
"jobId": "6a13efcec6b99f3fdfec4914",
"imageNo": 0,
"remixPrompt": "Change the panda to a tiger",
"mode": 0
}
3.10 Edit
Perform local editing on a specified area of the canvas.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Original Task ID |
| imageNo | integer | Yes | Original image number, with a value ranging from 0 to 3 |
| canvas | object | Yes | Canvas Size |
| canvas.width | integer | Yes | Canvas Width (pixels) |
| canvas.height | integer | Yes | Canvas Height (pixels) |
| imgPos | object | Yes | Position of the image on the canvas |
| imgPos.width | integer | Yes | Image Width (pixels) |
| imgPos.height | integer | Yes | Image Height (Pixels) |
| imgPos.x | integer | Yes | Horizontal Displacement (pixels) |
| imgPos.y | integer | Yes | Vertical Offset (Pixels) |
| remixPrompt | string | Yes | Edit Description Prompt |
| mask | object | No | Original image redrawing area (format is the same as that of 3.3 mask) |
Request Example
{
"jobId": "6a13efcec6b99f3fdfec4914",
"imageNo": 0,
"canvas": {
"width": 1024,
"height": 1024
},
"imgPos": {
"width": 512,
"height": 512,
"x": 256,
"y": 256
},
"remixPrompt": "Add a forest background"
}
3.11 Advanced Editor (Upload-Paint)
Upload any image URL and perform local redrawing on the area specified by the mask. Independent of the original task.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| imgUrl | string | Yes | URL of the image to be edited |
| mask | object | Yes | Mask definition (same format as 3.3 mask;areas[]. width/heightmust be ≥500) |
| canvas | object | Yes | Canvas size (format is the same as that of 3.10 canvas) |
| imgPos | object | Yes | The position of the image in the canvas (in the same format as 3.10 imgPos) |
| remixPrompt | string | Yes | Edit Description Prompt |
Request Example
{
"imgUrl": "https://example.com/image.png",
"mask": {
"areas": [{
"width": 1024,
"height": 1024,
"points": [0, 0, 0, 512, 512, 512, 512, 0]
}]
},
"canvas": {
"width": 1024,
"height": 1024
},
"imgPos": {
"width": 512,
"height": 512,
"x": 256,
"y": 256
},
"remixPrompt": "A beautiful mountain scene with trees"
}
Note:
mask.areas[]. widthandheightmust be ≥ 500, otherwise Youyun will return 400.
3.12 Retexture
Upload any image URL and use a new prompt to alter the overall style/texture of the image. Independent of the original task.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| imgUrl | string | Yes | URL address of the image to be traced |
| remixPrompt | string | Yes | Prompt words describing the target style |
Note: The trace function requires models of version v6.1 and above.
Request Example
3.13 Remove Background (Remove-Background)
Automatically cut out the subject and remove the background, returning a transparent PNG. Independent of the original task.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| imgUrl | string | Yes | URL address of the image to be processed |
Request Example
3.14 Enhance
Enhance the image quality of the graph generated in draft mode to the official quality level. Only supports tasks created via the --draftparameter.
Request URL
Request Parameters
| field | Type | Required | Description |
|---|---|---|---|
| jobId | string | Yes | Original Task ID (must be a draft-mode task) |
| imageNo | integer | Yes | Original image number, with a value range of 0-3 |
Request Example
IV. Overview of Interface Classification
4.1 Direct Generation (Independent of Original Task)
| interface | Path | Description |
|---|---|---|
| Text-to-Image | POST /tob/diffusion |
Text/Image-to-Image Generation |
| Senior Editor | POST /tob/upload-paint |
Upload image + partial mask redraw |
| redrawing | POST /tob/retexture |
Upload Image + Change Style |
| Remove Background | POST /tob/remove-background |
Upload Image + Automatic Background Removal |
4.2 Re-editing (based on the original task jobId)
| API | Path | Additional Required Parameters | Description |
|---|---|---|---|
| Redraw Area | POST /tob/inpaint |
imageNo, mask | Redraw the specified area |
| HD Zoom | POST /tob/upscale |
imageNo, type | improve resolution |
| change | POST /tob/variation |
imageNo, type | Retain compositional generation variants |
| Re-execute | POST /tob/reroll |
— | Regenerate a batch of |
| extend | POST /tob/pan |
imageNo, direction, scale | Extend in the specified direction |
| Expand Image | POST /tob/outpaint |
imageNo, scale | Uniformly expand equally in all directions |
| Reshape | POST /tob/remix |
imageNo, remixPrompt | Retain the composition while replacing the content |
| Edit | POST /tob/edit |
imageNo, canvas, imgPos, remixPrompt | Partial Editing on Canvas |
| Enhance | POST /tob/enhance |
imageNo | Draft tasks only |
V. Draft Mode Workflow
Applicable to scenarios requiring rapid iteration of ideas and cost reduction:
Step 1: POST /tob/diffusion
text: "description --draft"
→ Returns jobId (draft task, 0.5x cost, 10x speed)
Step 2: GET /tob/job/{jobId}
→ Poll until status=2 (success)
→ Pick a satisfactory image from urls[0-3] (imageNo 0-3)
Step 3: POST /tob/enhance
jobId: the jobId from the previous step
imageNo: the selected image number
→ Returns a high-quality final image
Restrictions:
--draftcannot be used together with--tile,--oref, or--q 4at the same time
6. Error Codes
| HTTP status code | reason | Description |
|---|---|---|
| 400 | Invalid_Argument | Invalid request parameters |
| 400 | VALIDATOR | Parameter validation failed (e. g. mask.areas[]. width < 500) |
| 400 | CODEC | Incompatible proto field |
| 402 | Account_Fee_Not_Enough | Insufficient account balance |
| 403 | Msg_Sensitive | The prompt contains sensitive content |
| 405 | Not_Support | The current operation is not supported (e. g., the enhance interface receives a non-draft task) |
| 429 | Max_Concurrent_Limited | The number of concurrent requests has reached the upper limit |
| 500 | Internal_Server_Error | Youchuan Server Internal Error |