Other APIs / open-api-images-generations(国内).md

Image Generation API (Unified Endpoint)

Overview

Image Generationendpoint:Request Body,model fieldcan imageModel, supported Text-to-Image (text-to-image) and Image-to-Image/Image Editing (image-to-image), supportedReference image, Aspect ratio and Resolution (1K/2K/4K) output.

endpointastask:Create Task after returntaskId, after query endpointPolling, orcallback_url in task complete when.

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

Description:endpoint and Image Generation/v1/images/generations Pathconsistent, when Usually Base URL and Token.

Authentication

with endpoint in Request in Token:```
Authorization: Bearer {YOUR_AUTH_TOKEN}


---

## Quick Start

### Create Text-to-Image Task

```bash

curl -X POST "https://mm-internal-cn.leonecloud.com/v1/images/generations" \
-H "Authorization: Bearer your_auth_token_here" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A surreal painting of a giant banana floating in space",
"size": "16:9",
"quality": "high"
}'


### Create Image-to-Image task (Reference image)```bash
curl -X POST "https://mm-internal-cn.leonecloud.com/v1/images/generations" \
 -H "Authorization: Bearer your_auth_token_here" \
 -H "Content-Type: application/json" \
 -d '{
 "model": "nano-banana-2",
 "prompt": "image, images",
 "image": [
 "https://example.com/ref1.jpg",
 "https://example.com/ref2.jpg"
 ],
 "size": "1:1",
 "quality": "high"
 }'

Query Task Status

curl -X GET "https://mm-internal-cn.leonecloud.com/api/v2/open/aigc/task_20260509150000_abc12345" \
 -H "Authorization: Bearer your_auth_token_here"

Endpoints

1. create Image Generationtask**POST** /v1/images/generations

Content-Type: application/json

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel, use imageModel, see below「supported Model」
promptstringYesimagePrompt
imagestring[]NoReference imagelist (URL or base64 data URI); Image-to-Image/.Model supported maximum images, see below「supported Model」
sizestringNoAspect ratioor Resolution.when Aspect ratio (16:9, 1:1); as1K/2K/4K when Resolution; supported1792x1024 pixel string, will.DefaultModel
qualitystringNoquality,high height Resolution output; Model, see below「supported Model」.localized example textresolution whenresolution as
resolutionstringNoResolutionlocalized example text1k / 2k / 4k, heightsize andquality.GPT Image 2 supported 1K/2K/4K,seedream-5.0-pro supported 1K/2K; Flux 2,1MP / 2MP / 3MP / 4MP; flux-3-image localized example text768SQ / 1K / 1.5K / 2K / 4K; mai-image-2.6 localized example text1K / 2K
nsfw_checkbooleanNoSafety moderation toggle.GPT Image 2, Flux 2 supported; andextra_body.nsfw_checker when in when field as
maskstringNoMaskimage (URL or base64 data URI),.onlyModel supported (gpt-image-2)
nintegerNoNumber of outputs, default 1; Modelsingle image output, will
image_urls / mask_urlmixedNoimage / mask,, can and
background / moderation / output_format / output_compression / usermixedNogpt-image-2-official andgpt-image-2-5-*-official imageParameter, Model
providerstringNoonly gpt-image-2-official andgpt-image-2-5-*-official supported:,oai / az, If omittedas ().after, can use when taskFailure and; Modelfield returncode=10002
extra_bodyobjectNoModelwith Parameter, Model, see below「Modelwith Parameter」
callback_urlstringNoCallback notification URL after the task is complete
task_nicknamestringNoTask label for business tracking
Description:
- size field「Aspect ratio」and「Resolutionlocalized example text」Meaning: when16:9 aspect ratio string, when1K/2K/4K., GPT Image 2 can use aspect ratio stringsize + resolution (), Model can usehigh localized example textquality, orextra_body Model with Resolutionfield ().
- Resolution tier priority:resolution > size localized example text> quality.localized example textsize=16:9 + resolution=4k 16:9 4K image.
- localized example textimage after as Image-to-Image/, Model will reference images to.
- image andmask supported URL or base64 data URI (data:image/jpeg;base64,...).

Request Example

Basic Text-to-Image:

{
 "model": "gpt-image-2",
 "prompt": "A surreal painting of a giant banana floating in space"
}

Resolution and dimensions:

{
 "model": "nano-banana-2",
 "prompt": "can in,,",
 "size": "16:9",
 "quality": "high"
}

Image-to-Image Editing (Single Reference):

{
 "model": "gpt-image-2",
 "prompt": "will image as, image",
 "image": ["https://example.com/input.jpg"],
 "size": "1:1"
}

(Mask):

{
 "model": "gpt-image-2",
 "prompt": "Mask as",
 "image": ["https://example.com/input.jpg"],
 "mask": "https://example.com/mask.png"
}

With Callback URL:

{
 "model": "seedream-5.0-pro",
 "prompt": ",",
 "size": "21:9",
 "quality": "high",
 "callback_url": "https://your-server.com/callback"
}

Response Parameters

ParameterTypeDescription
codeintStatus Code, 0 indicates success
msgstringMessage
data.taskIdstringTask ID, used to query task status
data.statusstringTask Status, fixed to processing
data.createdAtstringCreated Time

Response Example

Success

{
 "code": 0,
 "msg": "success",
 "data": {
 "taskId": "task_20260509150000_abc12345",
 "status": "processing",
 "createdAt": "2026-05-09 15:00:00"
 }
}

2. Query Task Status

GET /api/v2/open/aigc/{taskId}

query task execute Status.tasklocalized example textprocessing when「Best Practices」in the Polling,success orfailed.

Response Parameters

ParameterTypeDescription
codeintStatus Code, 0 indicates success
msgstringMessage
data.taskIdstringTask ID
data.statusstringTask Status:processing / success / failed
data.resultstring[]generated resultimage URL list (Successreturned when applicable)
data.progressint0-100
data.pointConsumestringlocalized example text
data.errorCodestringError Codes (Failurereturned when applicable)
data.errorMsgstringError Message (Failurereturned when applicable)
data.createdAtstringCreated Time
data.updatedAtstringUpdated Time

Response Example

Success

{
 "code": 0,
 "msg": "success",
 "data": {
 "taskId": "task_20260509150000_abc12345",
 "status": "success",
 "result": [
 "https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/2026/05/09/output_001.png"
 ],
 "progress": 100,
 "createdAt": "2026-05-09 15:00:00",
 "updatedAt": "2026-05-09 15:00:25"
 }
}

processing

{
 "code": 0,
 "msg": "success",
 "data": {
 "taskId": "task_20260509150000_abc12345",
 "status": "processing",
 "progress": 30,
 "createdAt": "2026-05-09 15:00:00",
 "updatedAt": "2026-05-09 15:00:08"
 }
}

supported Modelmodel fieldand Model Parameter.Model can.

model Values ()DescriptionReference imagemaximumimagesquality localized example text
gpt-image-2GPT Image 2(Prompt and )high 2K, 1K; or useresolution to explicitly set 1K/2K/4K (higher priority than quality)
gpt-image-2-officialOpenAI GPT Image 2, token, supported Text-to-Image, Image-to-Image, Mask and 1–4 images PNG/JPEG output.with Model EndpointPOST /api/v2/open/aigc/gpt-image-2-officialup to 16 imagesauto / low / medium / high
gpt-image-2-5-sunburst-officialGPT Image 2.5 Sunburst,,, image,.andgpt-image-2-official Parameter,quality localized example textxhigh / max localized example text.with 2.5 localized example textPOST /api/v2/open/aigc/gpt-image-2-5-official (localized example textgenType=sunburst )up to 16 imagesauto / low / medium / high / xhigh / max
gpt-image-2-5-flare-officialGPT Image 2.5 Flare,,, image,,.andgpt-image-2-5-sunburst-official Requestexactly identical, and token, onlyModel.with 2.5 localized example textPOST /api/v2/open/aigc/gpt-image-2-5-official (localized example textgenType=flare )up to 16 imagesauto / low / medium / high / xhigh / max
gpt-image-2-6-sunburst-officialGPT Image 2.6 Sunburst, and.OpenAI Parameter: supportedcomplexity, safety_identifier, markup,webp / gif / svg output and anyWIDTHxHEIGHT dimensions;provider onlysupportedoai.DescriptionGPT Image 2.6 Official.with 2.6 localized example textPOST /api/v2/open/aigc/gpt-image-2-6-official (localized example textgenType=sunburst )up to 16 imagesauto / low / medium / high / xhigh / max
gpt-image-2-6-flare-officialGPT Image 2.6 Flare, localized example text.andgpt-image-2-6-sunburst-official Requestexactly identical,, onlyModel.with 2.6 localized example textPOST /api/v2/open/aigc/gpt-image-2-6-official (localized example textgenType=flare )up to 16 imagesauto / low / medium / high / xhigh / max
gpt-image-2.6-sunburstGPT Image 2.6 Sunburst, and, Resolution each ( token).1 images, supportedmask; size supported 15, in1:3 / 3:1 with 2K/4K.DescriptionGPT Image 2.6.withPOST /api/v2/open/aigc/gpt-image-2.6 (localized example textgenType=sunburst )localized example text( height quality);resolution 1K/2K/4K
gpt-image-2.6-flareGPT Image 2.6 Flare, localized example text.andgpt-image-2.6-sunburst Requestexactly identical,, onlyModellocalized example textlocalized example text
gpt-image-2.5-sunburstGPT Image 2.5 Sunburst,, Resolution each ( token).1 images, supportedmask repainting;size supported 10.DescriptionGPT Image 2.5.withPOST /api/v2/open/aigc/gpt-image-2.5 (localized example textgenType=sunburst )up to 16 images( height quality);resolution 1K/2K/4K
gpt-image-2.5-flareGPT Image 2.5 Flare, localized example text.andgpt-image-2.5-sunburst Requestexactly identical,, onlyModelup to 16 imageslocalized example text
gpt-image-2-proGPT Image 2 Prolocalized example texthigh 2K, 1K; or useresolution to explicitly set 1K/2K/4K (higher priority than quality)
nano-banana-2Nano Banana 214high localized example text
nano-banana-2-1Nano Banana 2.110high localized example text
nano-banana-2-liteNano Banana 2 Lite10high localized example text
nano-banana-proNano Banana Pro8high localized example text
seedream-4.5Seedream 4.514basic(2K) / high(4K)
seedream-5.0-liteSeedream 5.0 Lite14basic(3K) / high(4K)
seedream-5.0-proSeedream 5.0 Pro10basic(1K) / high(2K)
qwen-image-3 (qwen-image-3.0)Qwen Image 3localized example texthigh 2K, 1K ( no 4K)
qwen-image-3-pro (qwen-image-3.0-pro)Qwen Image 3 Prolocalized example text( no 4K)
grok-imagine-1.5Grok Imagine 1.51 (only images )—
flux-2-proFlux 2 Pro, image and8localized example textresolution localized example text1MP / 2MP / 3MP / 4MP (default 1MP); quality=high etc.2MP
flux-2-flexFlux 2 Flex, and8localized example text
flux-2-maxFlux 2 Max, Flux 2 height8localized example text
flux-3-imageFLUX-3-IMAGE, Flux 3 imageModel, Reference image10localized example textresolution localized example text768SQ / 1K / 1.5K / 2K / 4K (default 1K); quality=high etc.2K
mai-image-2.6MAI-Image-2.6, height quality, token5supportedquality; localized example textresolution localized example text1K / 2K (default 1K)
mai-image-2.6-flashMAI-Image-2.6 Flash, andmai-image-2.6 Parameter,, Pricing5localized example text
muse-imageMuse Image, images, Reference image9 (localized example text≤11MB)no Resolution,quality / resolution localized example text
Description:
- Seedream localized example textquality onlylocalized example textbasic / high, will return ParameterError; Modelquality localized example texthigh localized example text.
- nano-banana-2 / nano-banana-2-1 / nano-banana-2-lite / qwen-image / Seedream / Flux 2 /flux-3-image Request output 1 images,n no;mai-image-2.6 localized example textn supported1, greater than 1 return ParameterError.
- Flux 2 localized example textsize Aspect ratio1:1 / 4:3 / 3:4 / 16:9 / 9:16 / 3:2 / 2:3 / 21:9 / 9:21, Image-to-Imagesupportedauto (number images Reference image),1:1; resolution localized example text1MP~4MP return ParameterError (1K / 2K, etc.1MP / 2MP).Reference image when Reference image, Flux 2.
- flux-3-image localized example textsize localized example textauto and 15 Aspect ratio21:9 / 2:1 / 16:9 / 3:2 / 7:5 / 4:3 / 5:4 / 1:1 / 4:5 / 3:4 / 5:7 / 2:3 / 9:16 / 1:2 / 9:21, localized example text1:1; auto Text-to-ImageModel prompt, Image-to-Image number images Reference image.resolution localized example text768SQ / 1K / 1.5K / 2K / 4K return ParameterError.Reference imageup to 10 images,; supportednsfw_check, FLUX-3-IMAGE.
- mai-image-2.6 localized example textsize Aspect ratio (1:4 localized example text4:1 any ), dimensions (1536x1024, width and height≥768, localized example text≤1536×1536)orauto, return ParameterError;resolution localized example text1K / 2K.Reference image when output dimensions Model ( 100 ),size / resolution localized example text.supportedmask, output PNG, MAI-Image-2.6 localized example text.
- muse-image localized example textsize localized example text1:1 / 16:9 / 9:16 / 4:3 / 3:4 / 3:2 / 2:3 orauto (If omittedorauto when Text-to-Imagedefault1:1, Reference imageReference image image ), return ParameterError;n supported1; supportedmask, output WebP, Muse Image.
- gpt-image-2.5- / gpt-image-2.6- (localized example text-official after )Resolution each, and*-official token:Model, Pricing, Parameter supported,.output 1 images (n no ),quality, Resolutionresolution andsize; 2.6 supportedmask.
- not imageModel ( Model)endpointmodel field, as.

Modelwith Parameter (extra_body)

Model supportedextra_body with Parameter:modelextra_body fieldDescription
gpt-image-2 / gpt-image-2-pronsfw_checker(bool); etc.nsfw_check, when as
grok-imagine-1.5nsfw_checker(bool)localized example text
nano-banana-2 / nano-banana-2-1output_format(jpg/png)Output format, default jpg
nano-banana-prooutput_format(png/jpg), aspect_ratio, resolution(1K/2K/4K)heightsize/quality
seedream-4.5 / seedream-5.0-litensfw_checker(bool)localized example text
seedream-5.0-pronsfw_checker(bool), genType(t2i/i2i, can-layer after ),layerDecomposition(bool)image provide images input image
qwen-image-3-propromptExtendMode(direct/agent)agent onlysupported Text-to-Image
flux-2-pro / flux-2-flex / flux-2-maxnsfw_checker(bool); etc.nsfw_check, when as
flux-3-imagesafety_tolerance(0~4), grounding(bool)safety_tolerance as, default2,, 0~4 return ParameterError;grounding default true, localized example text
mai-image-2.6 / mai-image-2.6-flashweb_grounding(bool), auto_aspect_ratio(bool), width / height(int)web_grounding, defaultfalse; auto_aspect_ratio=true etc.size=auto; width / height provide, heightsize

():```json
{
"model": "gpt-image-2",
"prompt": "a cat",
"extra_body": { "nsfw_checker": true }
}


---

## Callback Notification

task complete (Success or Failure) when, Create Task when provide`callback_url`, will URL POST Request.

### Callback Request

**Headers**

Content-Type: application/json
X-Funcloud-Event: task.completed
X-Funcloud-Signature: {localized example text}


**Body**
```json

{
"event": "task.completed",
"timestamp": "2026-05-09T15:00:25+08:00",
"signature": "a1b2c3d4e5f6...",
"data": {
"taskId": "task_20260509150000_abc12345",
"status": "success",
"result": ["https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/output_001.png"],
"progress": 100,
"createdAt": "2026-05-09 15:00:00",
"updatedAt": "2026-05-09 15:00:25"
}
}


> - `data` fieldand query endpoint return`data` localized example text.
> - `X-Funcloud-Signature` as HMAC-SHA256, can use, when in Header and Body`signature` field.
> - Failure will 5s / 30s / 180s.

---

## Error Codes

| code | Description |
|------|------|
| 0 | Success |
| 10002 | Parametermissing or malformed |
| 10005 | API Key invalid or missing |
| 30003 | Task not found |
| 40001 | Insufficient balance |
| 90003 | Internal server error |

---

## Best Practices

### 1. Polling Strategy

recommendedPolling:
- First 30 seconds:query every 3 seconds
- After 30 seconds:query every 5 seconds### 2. Use Callback

recommended use`callback_url` Callback NotificationPolling, can query Request.

### 3. Processing Time Reference

- Text-to-Image (1K):Usually 5 ~ 20 seconds
- Text-to-Image (2K/4K):Usually 10 ~ 30 seconds
- Image-to-Image editing:Usually 10 ~ 30 seconds

### 4. Resolution Selection

| Resolution | Scenario|
|--------|---------|
| 1K |,|
| 2K | height quality, asset|
| 4K |, dimensions|

### 5. when 

 image URL and when, when.
Updated 2026-11-19