Skip to main content
POST
/
ai
/
openai
/
images
/
generate
openai generate async
curl --request POST \
  --url https://ai.pmock.com/api/ai/openai/images/generate \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "<string>",
  "model": "gpt-image-2",
  "size": "auto",
  "n": 123,
  "quality": "auto",
  "background": "transparent",
  "outputFormat": "png",
  "outputCompression": 123,
  "moderation": "auto",
  "responseFormat": "url",
  "inputFidelity": "high",
  "image": [
    "<string>"
  ],
  "mask": "<string>"
}
'
{
  "code": 200,
  "message": "<string>",
  "data": {
    "taskId": "<string>"
  },
  "traceId": "<string>"
}
A unified entry point for image creation. The backend service automatically determines the action based on the request body:
  • Text-to-Image: If the image field is absent or null, it performs text-to-image generation.
  • Image Editing: If the image field is present, it performs image editing based on the provided image.

Body

application/json
prompt
string
required

prompt

Minimum string length: 1
model
enum<string>
required

model

Available options:
gpt-image-2
size
enum<string>

image size

Available options:
auto,
1024x1024,
1024x1536,
1536x1024
n
integer<int32>

Generation quantity (currently only supports 1)

quality
enum<string>

quality grade

Available options:
auto,
low,
medium,
high,
standard
background
enum<string>

background transparency

Available options:
transparent,
opaque,
auto
outputFormat
enum<string>

Output file format

Available options:
png,
jpeg,
webp
outputCompression
integer<int32>

JPEG/WebP compression level 0-100

moderation
enum<string>

Audit intensity

Available options:
auto,
low
responseFormat
enum<string>

Response format (compatible with DALL · E; The gpt image series always returns b64_json)

Available options:
url,
b64_json
inputFidelity
enum<string>

Input image fidelity (newly added in gpt-image-2, only effective for editing scenes); Generate can be ignored)

Available options:
high,
low
image
string[]

Enter an image (URL or base64 data URL). If provided, go through image editing; If not provided, use text and images. Support single or multiple sheets

mask
string

mask image (only for editing scenes, URL or base64 data URL); transparent areas will be redrawn

Response

200 - */*

OK

Unified return structure for response results

code
integer<int32>

Response status code

Example:

200

message
string

Response message

data
object

Response result

traceId
string

Response traceId