Search...
Menu

Image Editing (OpenAI)

Upload an original image and editing instructions to generate a modified image, subject to model capabilities.

Request

Item Description
Method POST
Path /v1/images/edits
Gateway URL https://ailink.nativex.com
Authentication Authorization: Bearer sk-xxxx; replace the placeholder with your API Key
Request format multipart/form-data

Replace MODEL_ID with a model from the Model Marketplace that supports this endpoint. Available models, parameters, and permissions depend on your account.

Parameters

Parameter Location Type Required Description
model Body string Yes A model that supports image editing
image Body file Yes Image to edit; format and size limits depend on the model
prompt Body string Yes Editing instructions
mask Body file No Models supporting masked editing accept a mask matching the original image dimensions
n Body integer No Output image count; this example uses 1
size Body string No Output dimensions; use values supported by the model
response_format Body string No url or b64_json; subject to model support
Image requirements vary between model generations. Do not apply an older model's PNG, square-image, or 4 MB limit to every model. Do not manually set the multipart boundary when uploading files.

Example

curl -X POST 'https://ailink.nativex.com/v1/images/edits' \
  -H 'Authorization: Bearer sk-xxxx' \
  -F 'model=MODEL_ID' \
  -F 'image=@input.png' \
  -F 'prompt=Change the background to blue while keeping the subject' \
  -F 'n=1'

Response

The following is a simplified response for readability. IDs, URLs, text, and usage values are illustrative.

{
  "created": 0,
  "data": [
    {
      "url": "https://example.com/generated.png"
    }
  ]
}
Field or result Description
data[] Generated image URLs or Base64 data

Error handling

For unsuccessful responses, check the HTTP status and error body first. Verify the API Key, model name, account balance, and parameters. If rate limited, reduce concurrency and retry later.

Last modified: 2026-11-17