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.
Before you start
https://api.ofox.ai/v1openai/gpt-image-2.5-sunburstThe samples use flare; sunburst is recommended for editingpip install openaiEdit an image
Every sample below was run verbatim. The result is saved as output.png in the current directory.
cURL
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.pngIf 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.
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.
cURL
# 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.pngProviders
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.
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
Usually not needed — the gateway routes automatically. Use it only to pin a specific provider.
Upload limits
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
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.