Skip to main content
POST
Gpt image 2

Authorizations

Authorization
string
header
required

API Key authentication, please include the Authorization field in the request header

Body

multipart/form-data
model
enum<string>
required

GPT Image 2 model and output resolution tier

Available options:
gpt-image-2,
gpt-image-2-2k,
gpt-image-2-4k
Example:

"gpt-image-2"

prompt
string
required

Image generation or editing instructions

Maximum string length: 32000
Example:

"Create a premium product photo on a clean studio background"

size
string

Output aspect ratio for text-to-image requests. Use auto, one of 1:1, 4:3, 3:4, 3:2, 2:3, 16:9, 9:16, 21:9, 5:4, or 4:5, or a common WxH pixel size such as 1920x1080 or 512x512. For image editing, pass a WxH pixel size such as 1024x1024. Delivered dimensions follow the selected model tier.

Example:

"16:9"

n
integer
default:1

Number of images to generate

Required range: 1 <= x <= 10
image
file[]

Optional reference images for image editing. Repeat the image field for multiple PNG, WebP, JPG, or JPEG files. The combined total of uploaded files and imageUrl entries cannot exceed 16.

Maximum array length: 16
imageUrl
string

Optional reference image URL for image editing. Separate multiple URLs with commas. The combined total of uploaded files and URLs cannot exceed 16.

mask
file

Optional PNG mask for image editing. It requires at least one reference image and must match the first image dimensions. Transparent areas are edited while non-transparent areas are preserved.

Response

200 - application/json

Task created successfully

General response

code
integer
required

Response status code: 1000=Success, 9999=Failure, 9000=Insufficient Credits

msg
string
required

Response message

data
object
required

General data response