HAI Gateway Docs

OpenAI

OpenAI Image Edit

Creates an edited or extended image given one or more source images and a prompt.

POSTv1/images/edits

Authorizations

Authorizationstringheaderrequired

Use the following format for authentication: Bearer sk-pat-YourAccessToken

The key value is your HAI Gateway Personal Access Token (starting with sk-pat-). No separate API key from OpenAI is required.

Base URL

Body Parameters

Content-Type: multipart/form-data

modelstringbodyrequired

Image model, e.g. gpt-image-2

imagefilebodyrequired

Reference image file(s). For multiple images, repeat the image[] field; GPT image series accepts up to 16 per request

promptstringbodyrequired

Edit description

maskfilebody

Mask image (requires alpha channel) specifying the area to edit

nintegerbody

Number of images to generate, default 1, range 1–10

sizestringbody

auto / 1024x1024 / 1536x1024 / 1024x1536

qualitystringbody

low / medium / high / auto

backgroundstringbody

Background mode: transparent / opaque / auto, default auto, GPT image series only

output_formatstringbody

Image encoding format: png / jpeg / webp, default png, GPT image series only

streambooleanbody

Whether to enable streaming (partial images), default false, GPT image series only

For full parameter descriptions, refer to the OpenAI official documentation.

cURL
cURL:Default
curl https://api.hai.network/openai/v1/images/edits \
  -H "Authorization: Bearer sk-pat-YourAccessToken" \
  -F "model=gpt-image-2" \
  -F "image[]=@body-lotion.png" \
  -F "image[]=@bath-bomb.png" \
  -F "image[]=@incense-kit.png" \
  -F "image[]=@soap.png" \
  -F "prompt=Create a lovely gift basket with these four items in it"
200
200:Default
{
  "created": 1713833628,
  "data": [
    {
      "b64_json": "..."
    }
  ],
  "usage": {
    "total_tokens": 100,
    "input_tokens": 50,
    "output_tokens": 50,
    "input_tokens_details": {
      "text_tokens": 10,
      "image_tokens": 40
    }
  }
}