GPT Image Editing
curl --request POST \
--url https://api.mixroute.ai/v1/images/editsimport requests
url = "https://api.mixroute.ai/v1/images/edits"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixroute.ai/v1/images/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mixroute.ai/v1/images/edits"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixroute.ai/v1/images/edits")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyImage Series
GPT Image Editing
GPT Image image editing fields, model constraints, and request examples.
GPT Image Editing
curl --request POST \
--url https://api.mixroute.ai/v1/images/editsimport requests
url = "https://api.mixroute.ai/v1/images/edits"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixroute.ai/v1/images/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.mixroute.ai/v1/images/edits"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixroute.ai/v1/images/edits")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyEdit one or more images with GPT Image using the OpenAI Images editing request format.
GPT Image 2 resolutions above 3686400 total pixels are experimental. These GPT models return Base64 image data; do not send DALL-E-specific
For masked editing, add the
POST https://api.mixroute.ai/v1/images/edits
Models
| Model ID | Capabilities and Limits |
|---|---|
gpt-image-2 | Generation and editing; flexible sizes; fixed high input fidelity. |
gpt-image-1.5 | Generation and editing; standard image sizes. |
gpt-image-1 | Generation and editing; standard image sizes. |
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Complete model ID from the table above. Set it explicitly for routing. |
prompt | string | Yes | Description of the desired output or edit, at most 32000 characters. |
image | file | file[] | Yes | PNG, JPEG, or WebP inputs, each under 50 MB, up to 16 images. Upload files as multipart form data; repeat image[] for multiple files. |
mask | file | No | PNG mask under 4 MB with the same pixel dimensions as the first source image. Fully transparent pixels identify the region to edit; a multi-image request applies the mask to its first image. |
input_fidelity | string | No | high or low for GPT Image 1 and 1.5. Omit this field for GPT Image 2, which always processes image inputs at high fidelity. |
n | integer | No | Number of output images, 1-10; default 1. |
size | string | No | Output dimensions, or auto (default). See the model-specific size rules below. |
quality | string | No | low, medium, high, or auto (default). |
background | string | No | auto (default), opaque, or transparent. Transparency requires PNG or WebP; support on GPT Image 2 is in preview. |
output_format | string | No | Encoded image format: png (default), jpeg, or webp. |
output_compression | integer | No | Compression setting from 0 to 100, default 100. Only applies to JPEG or WebP output. |
stream | boolean | No | Return server-sent events when true; default false. |
partial_images | integer | No | Streaming-only partial-image count, 0-3. With 0, the final image is sent without intermediate images; fewer partial images may arrive if generation finishes early. |
user | string | No | Stable identifier for the end user, used for abuse monitoring. Avoid raw personal information. |
Size Rules
| Model | Allowed Sizes |
|---|---|
| GPT Image 1 / 1.5 | auto, 1024x1024, 1536x1024, 1024x1536 |
| GPT Image 2 | auto or WIDTHxHEIGHT. Both edges must be divisible by 16; each edge is at most 3840 px; long/short ratio at most 3:1; total pixels 655360-8294400. |
response_format or style.
Use multipart/form-data, not a JSON image URL object. Let cURL or the SDK set the multipart boundary.
input_fidelity=auto/medium and a top-level images JSON array are not fields of this OpenAI request.Examples
Use your MixRoute key in theMIXROUTE_API_KEY environment variable. Requests use Authorization: Bearer .... Replace source-image placeholders with accessible images or local files before editing.
curl --request POST "https://api.mixroute.ai/v1/images/edits" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--form "model=gpt-image-2" \
--form "image[]=@source.png" \
--form "prompt=Make the mug blue while preserving its shape, lighting, and background." \
--form "size=1024x1024" \
--form "quality=low" \
--form "output_format=png"
Python
import os
import base64
from pathlib import Path
from openai import OpenAI
client = OpenAI(api_key=os.environ["MIXROUTE_API_KEY"], base_url="https://api.mixroute.ai/v1")
with open("source.png", "rb") as source:
result = client.images.edit(
model="gpt-image-2",
image=source,
prompt="Make the mug blue while preserving its shape, lighting, and background.",
size="1024x1024",
quality="low",
output_format="png",
)
Path("edited.png").write_bytes(base64.b64decode(result.data[0].b64_json))
mask file. For multiple references, provide additional image files; a mask still applies only to the first.
Response
Read each image fromdata[].b64_json and decode it using the requested output_format. Streaming returns partial/completed image events; use the final completed event for the final file.
GPT Image generation