Image / GPT Image

GPT Image 2 Image Generation

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.

Capabilitylocalized example textRequestFormat
Text-to-Image / Image-to-ImagePOST /v1/images/generationsapplication/json
Image Editing (upload a file)POST /v1/images/editsmultipart/form-data
Query Tasklocalized example textGET /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

ParameterTypeRequiredDescription
modelstringYesgpt-image-2 orgpt-image-2-pro
promptstringYesimagePrompt, up to 20,000 characters
imagestring[]Noinput imagelist (URL or Base64 data URI),Image-to-Image, up to 16 images
maskstringNoMaskimage (URL or Base64 data URI), andimage use.Maskin
sizestringNo, pixel string or1K / 2K / 4K, see below「and Resolution」
resolutionstringNoResolution tier 1k / 2k / 4k; higher priority than the tier in size or quality
nintNoNumber of outputs, 1–10, default 1.Number of outputs
qualitystringNoauto / low / medium / high; high in notresolution localized example textsize when 2K
nsfw_checkbooleanNoSafety moderation toggle; takes precedence over extra_body.nsfw_checker when both are sent
asyncbooleanNo, defaulttrue; localized example textfalse image and return OpenAI image
response_formatstringNoonly async=false when:url orb64_json
extra_bodyobjectNoModelwith Parameter,{"nsfw_checker": true}
callback_urlstringNoCallback notification URL after the task is complete
task_nicknamestringNoTask label for business tracking
userstringNo(OpenAI field)
Description:
- Image-to-Imageno Generation type,image Image-to-Image;mask repainting,mask mustandimage localized example text> - Reference imagesupported can URL, can Base64 data URI, single imagemaximum 10MB, supports jpg/png/gif/webp#### 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_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」,:ParameterTypeRequiredDescription
imagefileYesimage (),number images as image.multiple imageswhenimage fieldcan, up to 16 images
maskfileNoMaskimage ().Maskin
image_urlsstringNoURL Reference image ( can ), and upload a file can
mask_urlstringNoURL provide Mask image, notmask file when
extra_bodystringNoModelwith 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

ParameterTypeRequiredDescription
taskIdstringYesTask ID

Response Parameters

ParameterTypeDescription
codeintStatus Code, 0 indicates success
msgstringMessage
data.taskIdstringTask ID
data.statusstringTask Status:processing / success / failed
data.resultstring[]image URL list (Successreturned when applicable)
data.errorCodestringError Codes (Failurereturned when applicable)
data.errorMsgstringError Message (Failurereturned when applicable)
data.taskNicknamestringTask label (create when return )
data.progressint, 0-100
data.pointConsumestring(decimal characters)
data.createdAtstringCreated Time (characters)
data.updatedAtstringUpdated Time (characters)
data.createTimeintCreated Time (Unix seconds)
data.updateTimeintUpdated Time (Unix seconds)
data.completeTimeintcomplete when (Unix seconds, complete returned when applicable)
data.costTimeintwhen (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:1 no 4K;size or asauto when 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:codeDescription
0Success
10002Parametermissing or malformed / supported model
10005API Key invalid or missing
30003Task not found, taskId
40001Insufficient balance
90003Internal 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

3. Processing Time Reference

  • Text-to-Image:Usually 10 ~ 60 seconds
  • Image-to-Image:Usually 10 ~ 60 seconds
  • use,
  • can ( oil painting, watercolor, digital art etc. )
  • Image-to-Image when, prompt image
  • supported, Usually
---## v2 endpointlocalized example textv2 endpoint(OpenAI )
create PathPOST /api/v2/open/aigc/gpt-imagePOST /v1/images/generations
query PathGET /api/v2/open/aigc/{taskId}GET /v1/images/generations/{taskId}
fieldlocalized example textcamelCaseOpenAI field
Generation typeRequest Body genType (t2i / i2i / edit)no,image / mask localized example text
localized example textaspectRatiosize (pixel string and )
Reference imageimageUrls / base64File / base64FileListimage (URL or Base64 data URI)
MaskmaskUrl / maskFilemask
Image EditinggenType=edit, image URL/v1/images/edits, image upload a file
imagesupportedsupported (async=false)
OpenAI SDK localized example textNoYes
Query Tasksupported (POST /api/v2/open/aigc/batch, up to 100 )supported

v2 endpoint can use, task and.v2 fieldDescription and query endpointGPT Image v2 endpoint.

Updated 2026-10-23