Image Editing API
The image editing interface modifies the original image according to the prompt (such as changing the background, altering elements, stylizing, etc.). Both GPT-Image and the Gemini image series can be used.
Interface
POST https://api.4allapi.com/v1/images/editsmultipart/form-data format, main fields:
| Field | Description |
|---|---|
model | Image model name, such as gpt-image-2, gemini-3.1-flash-image |
image | Original image file (multiple allowed, image[]) |
prompt | Editing instruction |
Examples
curl https://api.4allapi.com/v1/images/edits \ -H "Authorization: Bearer $AIPROXY_KEY" \ -F model="gpt-image-2" \ -F image="@product.png" \ -F prompt="Replace the background with a cozy Christmas living room scene, keeping the product subject unchanged"resp = client.images.edit( model="gpt-image-2", image=open("product.png", "rb"), prompt="Replace the background with a seaside sunset scene",)print(resp.data[0].url or resp.data[0].b64_json[:50])Key Usage Notes
- For multiple inputs (such as a product image + a reference style image), pass multiple
imagefields in order, and specify each image’s role in the prompt; - Editing is charged per request as well, and the aspect ratio/resolution are still controlled by the model name suffix;
- To keep person/product consistency, explicitly state “keep the subject unchanged” in the prompt, and prefer an output tier with a resolution close to the original image;
- Timeout and retry strategies are the same as Image Call Best Practices.