Introduction

Text

Image

GeneratePOSTEditPOST

Video

词元兽-TokenMons词元兽-TokenMons
Get StartedAPI Reference
GPT-IMAGEGPT Image 2

GPT Image 2 · Edit

Image / GPT / GPT Image 2 / Edit

POST/v1/images/edits

Request parameters

Authorization

Add an Authorization header whose value is Bearer followed by your API key.

Authorization: Bearer ****************
Body parametersmultipart/form-datarequired
modelstringRequired
Model ID, fixed to `gpt-image-2`
promptstringRequired
Edit instruction, e.g. change the background to a snowy night
imagefileRequired
Image(s) to edit; can be sent multiple times (`image` or `image[]`)
maskfileOptional
Mask image marking the area to modify
nintegerOptional
Number of images, default `1`
sizestringOptional
Resolution, e.g. `1024x1024`
response_formatstringOptional
Return format. `url` only applies to models that support it (e.g. DALL-E); OpenAI gpt-image always returns `b64_json` and ignores this field.
Example
{  "model": "gpt-image-2",  "prompt": "change the background to a snowy night",  "image": "dog.png",  "size": "1024x1024"}

Request code samples

curl https://api.hotrouter.ai/v1/images/edits \  -H "Authorization: Bearer $API_KEY" \  -F "model=gpt-image-2" \  -F "prompt=change the background to a snowy night" \  -F "image=@dog.png" \  -F "size=1024x1024"

Response

200 · Success
createdintegerOptional
Creation timestamp (seconds)
dataarray[object]Required
Generated images
Example
{  "created": 1730000000,  "data": [    {      "b64_json": "<base64>"    }  ]}

GeneratePOST

Previous Page

GeneratePOST

Next Page

On this page

Request parametersRequest code samplesResponse
{
  "model": "gpt-image-2",
  "prompt": "change the background to a snowy night",
  "image": "dog.png",
  "size": "1024x1024"
}
curl https://api.hotrouter.ai/v1/images/edits \
  -H "Authorization: Bearer $API_KEY" \
  -F "model=gpt-image-2" \
  -F "prompt=change the background to a snowy night" \
  -F "image=@dog.png" \
  -F "size=1024x1024"
{
  "created": 1730000000,
  "data": [
    {
      "b64_json": "<base64>"
    }
  ]
}