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.io/v1openai/gpt-image-2.6-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.io/v1/images/edits \
-H "Authorization: Bearer YOUR_OFOX_API_KEY" \
-F "model=openai/gpt-image-2.6-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.io/v1/images/edits \
-H "Authorization: Bearer YOUR_OFOX_API_KEY" \
-F "model=openai/gpt-image-2.6-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.pngMarkup editing (markup)
Prepare a transparent PNG the same size as the original image as a markup layer, and circle, draw arrows or write on it to mark where to change; in the prompt, say what to do with the marked area. The model overlays the markup layer on the first image to understand your intent, and the markup does not appear in the output.
First, generate a markup layer with Python: draw a red circle on a transparent canvas.
# pip install pillow
from PIL import Image, ImageDraw
w, h = Image.open("input.png").size # same size as the original
layer = Image.new("RGBA", (w, h), (0, 0, 0, 0)) # fully transparent canvas
draw = ImageDraw.Draw(layer)
draw.ellipse([w * 0.3, h * 0.3, w * 0.7, h * 0.7], outline=(255, 0, 0, 255), width=12)
layer.save("markup.png")Then submit the original image together with the markup layer:
cURL
curl -s https://api.ofox.io/v1/images/edits \
-H "Authorization: Bearer YOUR_OFOX_API_KEY" \
-F "model=openai/gpt-image-2.6-sunburst" \
-F "image=@input.png" \
-F "markup=@markup.png" \
-F "prompt=Replace the object inside the red circle with a blue star, keep everything else unchanged" \
-F "quality=low" \
-o response.json
jq -r '.data[0].b64_json' response.json | base64 --decode > output.pngHow markup editing differs from inpainting: a mask uses its transparent area to define the region that may be repainted; a markup layer is a hint drawn for the model, used to point out the location and your intent.
Providers
You don’t need to pin a provider; the gateway routes requests automatically. For 2.5 and gpt-image-2, both Azure and OpenAI serve the edit endpoint; 2.6 is currently served by OpenAI only.
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 · 2markup · X-OfoxAI-Provider-TypeExpand
Supported by 2.6 and 2.5. The markup layer: same dimensions as the first image, containing transparent pixels; cannot be combined with mask. See Markup editing.
Usually not needed — the gateway routes automatically. Use it only to pin a specific provider. 2.6 currently accepts only openai.
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.