Skip to Content
ModelsGPT ImageEdit & combine images

Edit & combine images

Upload one or more images and change or merge them with a prompt.

Not writing code? See Generate images in your own tools.

POST/v1/images/editsShared parameters

Before you start

You needDetails
API keyCreate one in the OfoxAI console  and replace YOUR_OFOX_API_KEY in the code
EnvironmentcURL needs jq to decode the image; Python needs pip install openai; Node.js 18 or later, no dependencies
ImagesPut an input.png in the current directory; for combining images, add an input2.png too. PNG or JPEG, ≤ 15 MB each
TimeoutSet your client timeout to 600 seconds. High quality, large sizes or editing can take several minutes
Values used in the code
API URLhttps://api.ofox.ai/v1
Model IDopenai/gpt-image-2.5-sunburstThe samples use flare; sunburst is recommended for editing
API keyReplace YOUR_OFOX_API_KEY in the code with your key
Python depspip install openai

Edit an image

Every sample below was run verbatim. The result is saved as output.png in the current directory.

Terminal
curl -s https://api.ofox.ai/v1/images/edits \ -H "Authorization: Bearer YOUR_OFOX_API_KEY" \ -F "model=openai/gpt-image-2.5-flare" \ -F "image=@input.png" \ -F "prompt=Replace the background with a wooden table, keep the subject unchanged" \ -F "quality=low" \ -o response.json jq -r '.data[0].b64_json' response.json | base64 --decode > output.png

If you omit size, the model picks the output size, which may differ from the original. To keep the original size, pass it explicitly, e.g. size=1024x1024.

Writing the prompt

Say two things clearly: what to change, and what to keep.

Use caseExample prompt
Edit one imageReplace the background with a wooden tabletop and keep the subject unchanged
Combine imagesPut the subject of the first image on the background of the second image

With several images, refer to them in upload order as “the first image” and “the second image”. To change only a small part of the image, Inpainting is more reliable.

Combine several images

Send several reference images at once. Upload order is what “the first image” and “the second image” in your prompt refer to. Put input.png and input2.png in the current directory.

Terminal
# Up to 16 images per request, ≤ 15 MB each curl -s https://api.ofox.ai/v1/images/edits \ -H "Authorization: Bearer YOUR_OFOX_API_KEY" \ -F "model=openai/gpt-image-2.5-flare" \ -F "image[]=@input.png" \ -F "image[]=@input2.png" \ -F "prompt=Place the subject of the first image onto the background of the second" \ -F "quality=low" \ -o response.json jq -r '.data[0].b64_json' response.json | base64 --decode > output.png

Providers

You don’t need to pin a provider. For all three models, both Azure and OpenAI serve the edit endpoint, and the gateway routes requests automatically.

If you have content moderation requirements you can select a provider, but the edit endpoint only accepts the X-OfoxAI-Provider-Type header; extra_body in the form is ignored. Once a provider is selected, requests will not fall back to another provider if it is unavailable. See Selecting a provider.

Parameter values

Parameters specific to the edit endpoint. model, n, output_format and the rest work as in text to image — see Text to image · Parameter values.

Required
imagerequiredfileform

The image to edit. For several images, repeat the field as image[]; with the Python SDK, pass a list.

▸ Details

Reference images are billed as tokens too: a 1024×1024 reference image measured 1,024 input tokens, which is why editing costs more than text to image at the same size.

▶Advanced · 1X-OfoxAI-Provider-TypeExpand
X-OfoxAI-Provider-Typestringheader· valuesazure_foundryopenai

Usually not needed — the gateway routes automatically. Use it only to pin a specific provider.

Upload limits

ItemLimit
Each reference image≤ 15 MB
Whole request≤ 50 MB
Number of imagesNo gateway limit; keep it to 16 or fewer
FormatPNG, JPEG

The model scales reference images to about 1024 px. Files over 5 MB only make the upload slower; they do not improve the result.

Common errors

ErrorCauseFix
Invalid image file or modeThe uploaded image is not a standard PNG or JPEGRe-export as PNG or JPEG
Invalid file 'image[0]': unsupported mimetypeThe uploaded file is not an imageUpload a PNG, JPEG or WebP image
does not support the 'input_fidelity' parameterinput_fidelity was sentRemove it; this family always processes reference images at high fidelity
moderation_blockedThe prompt or reference image was blocked by the upstream safety systemChange the prompt or reference image and try again
provider_type_unavailableThe provider you pinned manually doesn’t serve this modelRemove the X-OfoxAI-Provider-Type header
Invalid sizeThe size you passed breaks one of the four rulesSee Size
404 model_not_foundModel ID misspelled or wrong caseCopy the model ID from this page

For other errors, see the full error table.

Official docs

OpenAI’s docs describe behavior when you call OpenAI directly. When you call through OfoxAI, the measured results in these pages take precedence. For example, you don’t need to pin a provider for editing.

Last updated on