Skip to content

GPT Image (Edits)

Edit, extend, or combine existing images with the GPT Image family. The same endpoint serves every supported GPT Image model, with the same parameters as text-to-image generation plus the image and mask inputs.

POST https://llm.siraya.ai/v1/images/edits

Supported Models

Model ID Description
gpt-image-2 Image editing with the GPT Image 2 model.
gpt-image-2.5-flare Speed-optimized GPT Image 2.5 editing.
gpt-image-2.5-sunburst Quality-optimized GPT Image 2.5 editing (~2x slower than Flare).

For text-to-image generation with these models, see GPT Image.

Authorization string Required
Your API Key (e.g., `Bearer `).

Body

model string Required
The ID of the model to use (e.g. gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst).
prompt string Required
Instructions for the edit or transformation.
image_urls array Required
JSON mode: a list of input image URLs or base64 data URLs — up to 16 images per request. (In multipart mode, send the image file field instead — see Input Modes.)
mask_url string
JSON mode: a mask URL or base64 data URL marking the region to edit. Must be a PNG with the same dimensions as the input image. (In multipart mode, send the mask file field instead.)
n integer Default: 1
The number of images to generate (1-10).
size string Default: auto
The dimensions of the edited image. Any WIDTHxHEIGHT value is accepted as long as both sides are multiples of 16, the aspect ratio is between 1:3 and 3:1, and the size does not exceed 3840x2160. Use auto to let the model pick.
quality string Default: auto
The quality of the edited image. Possible values: low, medium, high, auto — plus xhigh and max on the GPT Image 2.5 models.
background string Default: auto
The background type for the edited image. Possible values: transparent, opaque, auto. A transparent background requires output_format: png.
output_format string Default: png
The encoding of the returned image. Possible values: png, jpeg.
output_compression integer Default: 100
The compression level for the output image (0-100). Only valid with output_format: jpeg.
moderation string Default: auto
The content moderation level. Possible values: low, auto.
curl https://llm.siraya.ai/v1/images/edits \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <API_KEY>" \
  --data-raw '{
    "model": "gpt-image-2.5-flare",
    "prompt": "Replace the background with a sunset beach and keep the subject unchanged",
    "image_urls": [
        "https://resources.siraya.ai/image/example1.png"
    ],
    "n": 1,
    "size": "1536x1024",
    "quality": "high",
    "output_format": "png"
}'
from openai import OpenAI

client = OpenAI(
    api_key="<API_KEY>",
    base_url="https://llm.siraya.ai/v1"
)

result = client.images.edit(
    model="gpt-image-2.5-flare",
    image=open("base_image.png", "rb"),
    mask=open("mask.png", "rb"),
    prompt="Replace the background with a sunset beach and keep the subject unchanged",
    n=1,
    size="1536x1024",
    quality="high",
    extra_body={"output_format": "png"}
)

print(result.data[0].b64_json[:64])

Example Response

{
    "created": 1774716098,
    "data": [
        {
            "b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zUAAAAg3..."
        }
    ]
}

Input Modes

The edits endpoint accepts input images in two modes, with the same parameters in both:

  • JSON — pass image references as image_urls (an array of URLs or base64 data URLs) and an optional mask_url. This is the mode used in the cURL example above.
  • multipart/form-data — upload the image file(s) and an optional mask file directly. This is compatible with the OpenAI SDK's client.images.edit(image=open(...)).
curl https://llm.siraya.ai/v1/images/edits \
  -H "Authorization: Bearer <API_KEY>" \
  -F "model=gpt-image-2" \
  -F "image=@base_image.png" \
  -F "mask=@mask.png" \
  -F "prompt=Replace the background with a beach at sunset" \
  -F "size=1536x1024" \
  -F "quality=high"

Masks must be PNGs with the same dimensions as the image they apply to.

Visit the Models Directory to see all supported image-to-image models.