asOpenAI localized example text:Path, Request Bodyand OpenAIimages/generations,images/edits, can OpenAI SDK.in use v2 endpoint (POST /api/v2/open/aigc/gpt-image, camelCase Request Body, query )GPT Image v2 endpoint.task and, can.
Overview
GPT Image 2 Image Generationendpoint, supported Text-to-Image (text-to-image), Image-to-Image (image-to-image) and Image Editing.
Modelmodel localized example text:gpt-image-2.with height cangpt-image-2-pro, Request Parameters,, query and Method and exactly identical, only and.
| Capability | localized example text | RequestFormat |
|---|---|---|
| Text-to-Image / Image-to-Image | POST /v1/images/generations | application/json |
| Image Editing (upload a file) | POST /v1/images/edits | multipart/form-data |
| Query Tasklocalized example text | GET /v1/images/generations/{taskId} | — |
default:task booking after Usually 1 seconds returntaskId, query image;async=false can as, Request OpenAI image.
Base URL: https://mm-internal-cn.leonecloud.com
Authentication
All endpoints require a token in the request header for authentication:
Authorization: Bearer {YOUR_AUTH_TOKEN}Quick Start
Text-to-Image
curl -X POST "https://mm-internal-cn.leonecloud.com/v1/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A beautiful sunset over the ocean, oil painting style",
"size": "1792x1024"
}'Image-to-Image (localized example textimage Image-to-Image)```bash
curl -X POST "https://mm-internal-cn.leonecloud.com/v1/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "Transform this image into watercolor style",
"image": ["https://example.com/reference.jpg"],
"size": "1024x1024"
}'
**Image-to-Image (image input )**
```json{
"model": "gpt-image-2",
"prompt": "Combine the elements from these images into a new artwork",
"image": [
"https://example.com/image1.jpg",
"https://example.com/image2.jpg"
],
"size": "1:1"
}
**Image Editing** (image file )```bash
curl -X POST "https://mm-internal-cn.leonecloud.com/v1/images/edits" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=gpt-image-2" \
-F "prompt=localized example text" \
-F "size=1024x1024" \
-F "image=@/path/to/cat.png"Query Tasklocalized example text
curl "https://mm-internal-cn.leonecloud.com/v1/images/generations/task_20260509150000_abc12345" \
-H "Authorization: Bearer YOUR_API_KEY"Endpoints
1. create Image Generationtask**POST** /v1/images/generations
Content-Type: application/json
defaultlocalized example text——task bookingafter Usually 1 seconds returntaskId, etc. image.Requestimage whenasync=false, see below「localized example text」.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | gpt-image-2 orgpt-image-2-pro |
prompt | string | Yes | imagePrompt, up to 20,000 characters |
image | string[] | No | input imagelist (URL or Base64 data URI),Image-to-Image, up to 16 images |
mask | string | No | Maskimage (URL or Base64 data URI), andimage use.Maskin |
size | string | No | , pixel string or1K / 2K / 4K, see below「and Resolution」 |
resolution | string | No | Resolution tier 1k / 2k / 4k; higher priority than the tier in size or quality |
n | int | No | Number of outputs, 1–10, default 1.Number of outputs |
quality | string | No | auto / low / medium / high; high in notresolution localized example textsize when 2K |
nsfw_check | boolean | No | Safety moderation toggle; takes precedence over extra_body.nsfw_checker when both are sent |
async | boolean | No | , defaulttrue; localized example textfalse image and return OpenAI image |
response_format | string | No | only async=false when:url orb64_json |
extra_body | object | No | Modelwith Parameter,{"nsfw_checker": true} |
callback_url | string | No | Callback notification URL after the task is complete |
task_nickname | string | No | Task label for business tracking |
user | string | No | (OpenAI field) |
Description:
- Image-to-Imageno Generation type,imageImage-to-Image;maskrepainting,maskmustandimagelocalized example text> - Reference imagesupported can URL, can Base64 data URI, single imagemaximum 10MB, supports jpg/png/gif/webp#### Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | int | Status Code, 0 indicates success |
| msg | string | Message |
| data.taskId | string | Task ID, used to query task status |
| data.status | string | Task Status, fixed to processing |
| data.createdAt | string | Created Time |
Response Example
Success
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260423103000_abc12345",
"status": "processing",
"createdAt": "2026-04-23 10:30:00"
}
}2. Image Editing
POST /v1/images/edits
Content-Type: multipart/form-data
in images or multiple images image and Prompt, image / repainting /.and/v1/images/generations,fieldand Meaningexactly identical, in image and Mask file, no URL or Base64.task booking, query Methodexactly identical.
Request Parameters
| fieldand Meaning「create Image Generationtask」,: | Parameter | Type | Required | Description |
|---|---|---|---|---|
image | file | Yes | image (),number images as image.multiple imageswhenimage fieldcan, up to 16 images | |
mask | file | No | Maskimage ().Maskin | |
image_urls | string | No | URL Reference image ( can ), and upload a file can | |
mask_url | string | No | URL provide Mask image, notmask file when | |
extra_body | string | No | Modelwith Parameter, JSON characters,{"nsfw_checker":true} |
Request Example
image+ Mask
curl -X POST "https://mm-internal-cn.leonecloud.com/v1/images/edits" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=gpt-image-2" \
-F "prompt=localized example text" \
-F "n=2" \
-F "image=@/path/to/cat.png" \
-F "mask=@/path/to/mask.png"multiple imagesReference image
curl -X POST "https://mm-internal-cn.leonecloud.com/v1/images/edits" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=gpt-image-2" \
-F "prompt=images image Scenario" \
-F "image=@/path/to/img1.png" \
-F "image=@/path/to/img2.png"Response Example
and「create Image Generationtask」exactly identical:
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260423103000_edit5678",
"status": "processing",
"createdAt": "2026-04-23 10:30:00"
}
}3. Query Task Status
GET /v1/images/generations/{taskId}
/v1/images/generations and/v1/images/edits create task query.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| taskId | string | Yes | Task ID |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | int | Status Code, 0 indicates success |
| msg | string | Message |
| data.taskId | string | Task ID |
| data.status | string | Task Status:processing / success / failed |
| data.result | string[] | image URL list (Successreturned when applicable) |
| data.errorCode | string | Error Codes (Failurereturned when applicable) |
| data.errorMsg | string | Error Message (Failurereturned when applicable) |
| data.taskNickname | string | Task label (create when return ) |
| data.progress | int | , 0-100 |
| data.pointConsume | string | (decimal characters) |
| data.createdAt | string | Created Time (characters) |
| data.updatedAt | string | Updated Time (characters) |
| data.createTime | int | Created Time (Unix seconds) |
| data.updateTime | int | Updated Time (Unix seconds) |
| data.completeTime | int | complete when (Unix seconds, complete returned when applicable) |
| data.costTime | int | when (seconds, complete returned when applicable) |
Response Example
processing
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260423103000_abc12345",
"status": "processing",
"createdAt": "2026-04-23 10:30:00",
"updatedAt": "2026-04-23 10:30:05"
}
}Success
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260423103000_abc12345",
"status": "success",
"result": [
"https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/2026/04/23/output_001.png"
],
"createdAt": "2026-04-23 10:30:00",
"updatedAt": "2026-04-23 10:31:30"
}
}Failure
{
"code": 0,
"msg": "success",
"data": {
"taskId": "task_20260423103000_abc12345",
"status": "failed",
"errorMsg": "Failure:",
"createdAt": "2026-04-23 10:30:00",
"updatedAt": "2026-04-23 10:30:45"
}
}and Resolutionsize localized example text16:9 aspect ratio string,1024x1024, 1792x1024 pixel string, can1K / 2K / 4K localized example text.
pixel string when, will Aspect ratio, as1:1 / 16:9 / 9:16 / 4:3 / 3:4 / 21:9.localized example text1792x1024 → 16:9, 1024x1024 → 1:1; notsize when use Modeldefault.
Resolutionasresolution > size localized example text> quality.localized example text{"size":"16:9","resolution":"4k"} 16:9 4K image;{"size":"2K"} default 2K image; If omitted when default 1K.
Model ResolutionLimit:1:1no 4K;sizeor asautowhen 1K.
(async=false)
as OpenAI image, can OpenAI SDK:```json
{
"created": 1778394000,
"data": [
{ "url": "https://.../output_001.png" }
]
}
localized example text`response_format=b64_json` when,`data` as`{"b64_json":"..."}`.
> 4K image when: when width 10 minutes; Scenariorecommended use default, when.
---
## Callback Notification
task complete (Success or Failure) when, if Create Task when provide`callback_url`, was provided when creating the task, the system sends a POST request to that URL.
### Callback Request
**Headers**Content-Type: application/json
X-Funcloud-Event: task.completed
X-Funcloud-Signature: {localized example text}
**Body**
Callback Requestas, task in`data` fieldin ( and「Query Task Status」endpointlocalized example text`data` exactly identical):
```json{
"event": "task.completed",
"timestamp": "2026-04-23T10:31:30+08:00",
"signature": "a1b2c3d4e5f6...",
"data": {
"taskId": "task_20260423103000_abc12345",
"status": "success",
"result": ["https://fc-gw-sh.oss-accelerate.aliyuncs.com/images/output_001.png"],
"createdAt": "2026-04-23 10:30:00",
"updatedAt": "2026-04-23 10:31:30"
}
}
| field | Type | Description |
|-----|------|------|
| event | string | Type,`task.completed` |
| timestamp | string | when (RFC3339)|
| signature | string |, HMAC-SHA256(`taskId` + `timestamp`), when`X-Funcloud-Signature`, can use|
| data | object | task, and「Query Task Status」endpointreturn`data` exactly identical |
### Callback Response
return HTTP 2xx Status Codeindicates success:```json
{
"code": 0,
"msg": "ok"
}Error Codes
(default)Error, HTTP Status Code as 200,code: | code | Description |
|---|---|---|
| 0 | Success | |
| 10002 | Parametermissing or malformed / supported model | |
| 10005 | API Key invalid or missing | |
| 30003 | Task not found, taskId | |
| 40001 | Insufficient balance | |
| 90003 | Internal server error |
(async=false)OpenAI Error, and use HTTP Status Code:400 ParameterError, 401 Failure,402 Insufficient balance, 500 taskexecute Failure,504 etc. exceeds 10 minutes not image (tasknot, error.code localized example texttaskId, can query ).
Best Practices
1. Polling Strategy
recommendedPolling:
- First 30 seconds:query every 3 seconds
- 30 seconds~ 2 minutes:query every 5 seconds
- After 2 minutes:query every 10 seconds
2. Use Callback, recommended use Callback NotificationPolling, can: - reduce API calls - receive result notifications faster - reduce server load
3. Processing Time Reference
- Text-to-Image:Usually 10 ~ 60 seconds
- Image-to-Image:Usually 10 ~ 60 seconds
4. Prompt recommended
- use,
- can ( oil painting, watercolor, digital art etc. )
- Image-to-Image when, prompt image
- supported, Usually
| ---## v2 endpoint | localized example text | v2 endpoint | (OpenAI ) |
|---|---|---|---|
| create Path | POST /api/v2/open/aigc/gpt-image | POST /v1/images/generations | |
| query Path | GET /api/v2/open/aigc/{taskId} | GET /v1/images/generations/{taskId} | |
| fieldlocalized example text | camelCase | OpenAI field | |
| Generation type | Request Body genType (t2i / i2i / edit) | no,image / mask localized example text | |
| localized example text | aspectRatio | size (pixel string and ) | |
| Reference image | imageUrls / base64File / base64FileList | image (URL or Base64 data URI) | |
| Mask | maskUrl / maskFile | mask | |
| Image Editing | genType=edit, image URL | /v1/images/edits, image upload a file | |
| image | supported | supported (async=false) | |
| OpenAI SDK localized example text | No | Yes | |
| Query Task | supported (POST /api/v2/open/aigc/batch, up to 100 ) | supported |
v2 endpoint can use, task and.v2 fieldDescription and query endpointGPT Image v2 endpoint.