GPT-Image-2 - Image Edit
Clean gpt image 1 image edit. Fast and effective AI-powered photo editing for everyday creative needs.
POST
/
v1
/
images
/
edits
GPT-Image-2 | Image Edit
curl --request POST \
--url https://gptproto.com/v1/images/editsimport requests
url = "https://gptproto.com/v1/images/edits"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://gptproto.com/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://gptproto.com/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://gptproto.com/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://gptproto.com/v1/images/edits")
.asString();require 'uri'
require 'net/http'
url = URI("https://gptproto.com/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_bodyAuthentication
- Sign up for a GPTProto account at https://gptproto.com
- Navigate to the API Keys section in your dashboard
- Generate a new API key (sk-xxxxx)
- Copy and securely store your API key For authentication details, please refer to the Authentication section.
Initiate Request
curl --location 'https://gptproto.com/v1/images/edits' \
--header 'Authorization: GPTPROTO_API_KEY' \
--form 'model="gpt-image-2"' \
--form 'image[]=@"/path/to/file"' \
--form 'prompt="Put a hat on the cat"'
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('model', 'gpt-image-2');
data.append('image[]', fs.createReadStream('/path/to/file'));
data.append('prompt', 'Put a hat on the cat');
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://gptproto.com/v1/images/edits',
headers: {
'Authorization': 'GPTPROTO_API_KEY',
...data.getHeaders()
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import http.client
import mimetypes
from codecs import encode
conn = http.client.HTTPSConnection("gptproto.com")
dataList = []
boundary = 'wL36Yn8afVp8Ag7AmP8qZ0SA4n1v9T'
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=model;'))
dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))
dataList.append(encode("gpt-image-2"))
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=image[]; filename={0}'.format('file')))
fileType = mimetypes.guess_type('/path/to/file')[0] or 'application/octet-stream'
dataList.append(encode('Content-Type: {}'.format(fileType)))
dataList.append(encode(''))
with open('/path/to/file', 'rb') as f:
dataList.append(f.read())
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=prompt;'))
dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))
dataList.append(encode("Put a hat on the cat"))
dataList.append(encode('--'+boundary+'--'))
dataList.append(encode(''))
body = b'\r\n'.join(dataList)
payload = body
headers = {
'Authorization': 'GPTPROTO_API_KEY',
'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("POST", "/v1/images/edits", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"bytes"
"mime/multipart"
"os"
"path/filepath"
"net/http"
"io"
)
func main() {
url := "https://gptproto.com/v1/images/edits"
method := "POST"
payload := &bytes.Buffer{}
writer := multipart.NewWriter(payload)
_ = writer.WriteField("model", "gpt-image-2")
file, errFile2 := os.Open("/path/to/file")
defer file.Close()
part2,
errFile2 := writer.CreateFormFile("image[]",filepath.Base("/path/to/file"))
_, errFile2 = io.Copy(part2, file)
if errFile2 != nil {
fmt.Println(errFile2)
return
}
_ = writer.WriteField("prompt", "Put a hat on the cat")
err := writer.Close()
if err != nil {
fmt.Println(err)
return
}
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "GPTPROTO_API_KEY")
req.Header.Set("Content-Type", writer.FormDataContentType())
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Response Example
Response Example
{
"created": 1776843003,
"background": "opaque",
"data": [
{
"b64_json": "<BASE64_DATA>"
}
],
"output_format": "png",
"quality": "low",
"size": "1024x1024",
"usage": {
"input_tokens": 8,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 8
},
"output_tokens": 196,
"output_tokens_details": {
"image_tokens": 196,
"text_tokens": 0
},
"total_tokens": 204
}
}
Parameters
- Text to Image
- Image Edit
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
model | string | ✅ Yes | gpt-image-1 | gpt-image-1gpt-image-1-minigpt-image-1.5gpt-image-2 | The model to use for image generation. Defaults to gpt-image-1. |
prompt | string | ✅ Yes | - | - | A text description of the desired image(s). The maximum length is 32000 characters. |
n | integer | ❌ No | 1 | 1-10 | The number of images to generate. Must be between 1 and 10. |
size | string | ❌ No | auto | auto1024x10241536x10241024x15362048x20482048x11523840x21602160x3840or any valid custom size | The size of the generated images. For gpt-image-1: one of auto, 1024x1024, 1536x1024, or 1024x1536. For gpt-image-2: supports arbitrary resolutions (max edge ≤ 3840px, both sides must be multiples of 16px, aspect ratio ≤ 3:1, total pixels between 655,360 and 8,294,400). Outputs exceeding 2560×1440 are considered experimental. |
quality | string | ❌ No | auto | autohighmediumlow | The quality of the generated images. One of auto, low, medium, or high. Defaults to auto. Not supported by -plus suffixed models. |
background | string | ❌ No | auto | opaqueautotransparent | Allows to set transparency for the background of the generated image(s). transparent is only supported by gpt-image-1 (not gpt-image-2) and requires output_format to be png or webp. When auto is used, the model will automatically determine the best background. |
moderation | string | ❌ No | auto | lowauto | Content moderation level for generated images. low is less restrictive, auto is the default. |
output_format | string | ❌ No | auto | autopngjpegwebp | The output format of the generated image(s). Defaults to auto. jpeg is faster than png for latency-sensitive scenarios. |
output_compression | integer | ❌ No | 100 | 0-100 | The compression level (0-100%) for the output image. Only applicable with webp or jpeg format. Defaults to 100. |
stream | boolean | ❌ No | false | truefalse | Whether to stream the response in real-time. When enabled, partial images can be received during generation. |
partial_images | integer | ❌ No | - | 0-3 | The number of partial images to receive during streaming. Only used when stream is true. Each partial image incurs an additional 100 image output tokens. |
user | string | ❌ No | - | - | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. |
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
model | string | ✅ Yes | gpt-image-1 | gpt-image-1gpt-image-1-minigpt-image-1.5gpt-image-2 | The model to use for image editing. Defaults to gpt-image-1. |
prompt | string | ✅ Yes | - | 1–32000 chars | A text description of the desired image edit. |
images | file | ✅ Yes | - | max 16 images < 50MB each | The input image(s) to edit. Each image should be a png, webp, or jpg file. You can provide up to 16 images. |
mask | file | ❌ No | - | - | An additional image whose fully transparent areas indicate where the image should be edited. |
input_fidelity | string | ❌ No | - | highlow | Controls how faithfully the model preserves the original input image. Only supported by gpt-image-1. gpt-image-2 always uses high fidelity. |
n | integer | ❌ No | 1 | 1-10 | The number of images to generate. Must be between 1 and 10. |
size | string | ❌ No | auto | auto1024x10241536x10241024x15362048x20482048x11523840x21602160x3840or any valid custom size | The size of the generated images. For gpt-image-1: one of auto, 1024x1024, 1536x1024, or 1024x1536. For gpt-image-2: supports arbitrary resolutions (max edge ≤ 3840px, both sides must be multiples of 16px, aspect ratio ≤ 3:1, total pixels between 655,360 and 8,294,400). |
quality | string | ❌ No | auto | autohighmediumlow | The quality of the generated images. One of auto, low, medium, or high. Defaults to auto. Not supported by -plus suffixed models. |
background | string | ❌ No | auto | opaqueautotransparent | Allows to set transparency for the background of the generated image(s). transparent is only supported by gpt-image-1 (not gpt-image-2) and requires output_format to be png or webp. |
moderation | string | ❌ No | auto | lowauto | Content moderation level for generated images. low is less restrictive, auto is the default. |
output_format | string | ❌ No | auto | autopngjpegwebp | The output format of the generated image(s). Defaults to auto. jpeg is faster than png for latency-sensitive scenarios. |
output_compression | integer | ❌ No | 100 | 0-100 | The compression level (0-100%) for the output image. Only applicable with webp or jpeg format. Defaults to 100. |
stream | boolean | ❌ No | false | truefalse | Whether to stream the response in real-time. When enabled, partial images can be received during generation. |
partial_images | integer | ❌ No | - | 0-3 | The number of partial images to receive during streaming. Only used when stream is true. Set to 0 for a single streaming event with the complete image. Each partial image incurs an additional 100 image output tokens. |
user | string | ❌ No | - | - | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. |
Error Codes
Common Error Codes
| Error Code | Error Name | Description |
|---|---|---|
| 401 | Unauthorized | API key is missing or invalid |
| 403 | Forbidden | Your API key doesn’t have permission to access this resource, or insufficient balance for the requested operation |
| 429 | Too Many Requests | You’ve exceeded your rate limit |
| 500 | Internal server error | An internal server error occurred |
| 503 | Content policy violation | Content blocked due to safety concerns (actual status code is 400) |
⌘I

