gpt-image-2.6-sunburst
Image Edit
POST
/
v1
/
images
/
edits
Authorization
- Auth Type:
Bearer Auth(In:header) - Format:
Authorization: Bearer <YOUR_API_KEY> - Description: Use
Bearer <YOUR_API_KEY>. Format:Authorization: Bearer sk-xxxxxx. - API Key: where API Key is your AGCloud API KEY
gpt-image-2.6-sunburst. The multipart examples match the existing gateway upload convention; the path is /v1/images/edits (plural images).
Request Examples
curl --fail-with-body 'https://aiandgpu.com/v1/images/edits' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--form 'model=gpt-image-2.6-sunburst' \
--form 'image[]=@input.png' \
--form 'prompt=Change the background to a sunset while preserving the subject.' \
--form 'quality=medium' \
--form 'output_format=png'
import base64
import requests
with open("input.png", "rb") as source:
response = requests.post(
"https://aiandgpu.com/v1/images/edits",
headers={"Authorization": "Bearer <YOUR_API_KEY>"},
files=[("image[]", ("input.png", source, "image/png"))],
data={
"model": "gpt-image-2.6-sunburst",
"prompt": "Change the background to a sunset while preserving the subject.",
"quality": "medium",
"output_format": "png",
},
timeout=600,
)
response.raise_for_status()
with open("edited.png", "wb") as result:
result.write(base64.b64decode(response.json()["data"][0]["b64_json"]))
// Node.js 18+; save as an .mjs file.
import { readFile, writeFile } from "node:fs/promises";
const form = new FormData();
form.append("model", "gpt-image-2.6-sunburst");
form.append("image[]", new Blob([await readFile("input.png")], { type: "image/png" }), "input.png");
form.append("prompt", "Change the background to a sunset while preserving the subject.");
form.append("quality", "medium");
form.append("output_format", "png");
const response = await fetch("https://aiandgpu.com/v1/images/edits", {
method: "POST",
headers: { Authorization: "Bearer <YOUR_API_KEY>" },
body: form,
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
await writeFile("edited.png", Buffer.from(data.data[0].b64_json, "base64"));
// Save as edit_image.go; run with go run edit_image.go.
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
"time"
)
func main() {
var body bytes.Buffer
writer := multipart.NewWriter(&body)
fields := map[string]string{
"model": "gpt-image-2.6-sunburst",
"prompt": "Change the background to a sunset while preserving the subject.",
"quality": "medium",
"output_format": "png",
}
for key, value := range fields {
if err := writer.WriteField(key, value); err != nil { panic(err) }
}
source, err := os.Open("input.png")
if err != nil { panic(err) }
defer source.Close()
part, err := writer.CreateFormFile("image[]", "input.png")
if err != nil { panic(err) }
if _, err = io.Copy(part, source); err != nil { panic(err) }
if err = writer.Close(); err != nil { panic(err) }
req, err := http.NewRequest("POST", "https://aiandgpu.com/v1/images/edits", &body)
if err != nil { panic(err) }
req.Header.Set("Authorization", "Bearer <YOUR_API_KEY>")
req.Header.Set("Content-Type", writer.FormDataContentType())
client := &http.Client{Timeout: 10 * time.Minute}
res, err := client.Do(req)
if err != nil { panic(err) }
defer res.Body.Close()
result, err := io.ReadAll(res.Body)
if err != nil { panic(err) }
if res.StatusCode >= 400 { panic(string(result)) }
fmt.Println(string(result))
}
// Java 11+; save as EditImage.java. No third-party dependencies.
import java.io.ByteArrayOutputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.UUID;
public class EditImage {
private static void field(ByteArrayOutputStream body, String boundary,
String name, String value) throws Exception {
String part = "--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"" + name + "\"\r\n\r\n"
+ value + "\r\n";
body.write(part.getBytes(StandardCharsets.UTF_8));
}
public static void main(String[] args) throws Exception {
String boundary = "Boundary" + UUID.randomUUID();
ByteArrayOutputStream body = new ByteArrayOutputStream();
field(body, boundary, "model", "gpt-image-2.6-sunburst");
field(body, boundary, "prompt", "Change the background to a sunset while preserving the subject.");
field(body, boundary, "quality", "medium");
field(body, boundary, "output_format", "png");
String imageHeader = "--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"image[]\"; filename=\"input.png\"\r\n"
+ "Content-Type: image/png\r\n\r\n";
body.write(imageHeader.getBytes(StandardCharsets.UTF_8));
body.write(Files.readAllBytes(Path.of("input.png")));
body.write(("\r\n--" + boundary + "--\r\n").getBytes(StandardCharsets.UTF_8));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://aiandgpu.com/v1/images/edits"))
.timeout(Duration.ofMinutes(10))
.header("Authorization", "Bearer <YOUR_API_KEY>")
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofByteArray(body.toByteArray()))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) throw new RuntimeException(response.body());
System.out.println(response.body());
}
}
<?php
// Requires the PHP cURL extension.
$imagePath = realpath("input.png");
if ($imagePath === false || !is_readable($imagePath)) {
throw new RuntimeException("input.png is missing or unreadable");
}
$curl = curl_init("https://aiandgpu.com/v1/images/edits");
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_TIMEOUT => 600,
CURLOPT_HTTPHEADER => ["Authorization: Bearer <YOUR_API_KEY>"],
CURLOPT_POSTFIELDS => [
"model" => "gpt-image-2.6-sunburst",
"prompt" => "Change the background to a sunset while preserving the subject.",
"quality" => "medium",
"output_format" => "png",
"image[]" => new CURLFile($imagePath, "image/png", "input.png"),
],
]);
try {
$response = curl_exec($curl);
if ($response === false) throw new RuntimeException(curl_error($curl));
if (curl_getinfo($curl, CURLINFO_HTTP_CODE) >= 400) {
throw new RuntimeException($response);
}
echo $response;
} finally {
curl_close($curl);
}
// .NET 6+ console application.
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using var client = new HttpClient { Timeout = TimeSpan.FromMinutes(10) };
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "<YOUR_API_KEY>");
using var form = new MultipartFormDataContent();
form.Add(new StringContent("gpt-image-2.6-sunburst"), "model");
form.Add(new StringContent("Change the background to a sunset while preserving the subject."), "prompt");
form.Add(new StringContent("medium"), "quality");
form.Add(new StringContent("png"), "output_format");
using var source = File.OpenRead("input.png");
using var image = new StreamContent(source);
image.Headers.ContentType = new MediaTypeHeaderValue("image/png");
form.Add(image, "image[]", "input.png");
using var response = await client.PostAsync(
"https://aiandgpu.com/v1/images/edits", form
);
var content = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) throw new HttpRequestException(content);
Console.WriteLine(content);
data[0].b64_json to save the image, as shown in the Python and JavaScript examples.
The success response is illustrative; replace the Base64 placeholder with actual image data before decoding. OpenAI GPT Image responses use data[].b64_json, not image URLs. Do not send response_format or style; describe the desired style in prompt.
Request Parameters
See the OpenAI edit reference. Checked November 12, 2026.| Field | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | ✅ (select this model) | gpt-image-2.5-sunburst (upstream) | Explicitly set gpt-image-2.6-sunburst; omission selects a different upstream model. |
prompt | string | ✅ | - | 1–32,000 characters. |
image[] | file[] | ✅ (multipart) | - | Up to 16 input images; upload form used by this project. |
mask | file / object | - | - | Multipart file or JSON reference. Transparency indicates the editing region; match source dimensions and include an alpha channel. |
images | object[] | ✅ (JSON only) | - | 1–16 objects using file_id or image_url (URL or Base64 data URL). Do not combine with multipart fields. Gateway JSON-route support is not established by the template. |
markup | object | - | - | JSON image reference to a transparent PNG matching the first image after orientation. Mutually exclusive with mask. The 2.6 guide confirms support; the reference still names 2.5. Gateway passthrough must support the representation. |
n | integer | - | 1 | 1–10; default 1. |
size | string | - | auto | default auto; standard sizes include 1024x1024, 1536x1024, 1024x1536. |
quality | string | - | auto | auto (default), low, medium, high. |
background | string | - | auto | auto (default), opaque, transparent; transparency requires PNG/WebP. |
output_format | string | - | png | png, jpeg, webp, gif; SVG is listed in the schema but contradicted by the guide, so SVG editing is not promised. |
output_compression | integer | - | Not specified | 0–100; JPEG/WebP only. The edit reference does not declare a default. |
moderation | string | - | auto | auto (default) or low. |
stream | boolean | - | false | default false; consume SSE rather than a single JSON document when enabled. |
partial_images | integer | - | 0 | 0–3, default 0; streaming previews may be fewer than requested. |
safety_identifier | string | - | - | privacy-preserving end-user identifier, at most 128 characters. |
user | string | - | - | deprecated fallback; prefer safety_identifier. |
complexity | string | - | high | low, medium, high; default high. Planning effort is separate from rendering quality. |
frame_count | integer | - | 9 | GIF only, integer 2–16, default 9. |
frame_duration_ms | integer | - | 200 | GIF only, integer, default 200. The guide specifies 20–2000 ms and 10 ms rounding; the reference specifies a minimum of 20 and an encoded delay cap, which is not a confirmed request maximum. Use the guide range. |
svg | object | - | - | optional author-selection object. Send only when SVG model selection is enabled; then supply svg.model. Optional svg.reasoning.effort uses the author’s supported subset of none, minimal, low, medium, high, xhigh, max. Otherwise omit svg. |
input_fidelity support is not established for this model; omit it. Do not send legacy response_format or style. SVG editing is not promised because the upstream guide and edit schema conflict.