DEV Community

Cover image for GPT Image 2.6: Build a Preservation-Aware Two-Stage Editing Pipeline
Germey
Germey

Posted on Edited on

GPT Image 2.6: Build a Preservation-Aware Two-Stage Editing Pipeline

GPT Image 2.6 is most useful in production when you stop treating every prompt as a fresh generation. A product image, game character, or campaign visual usually contains approved details that must survive revision: a logo, silhouette, camera angle, palette, or layout. The engineering problem is therefore not simply “make an image,” but change one thing while proving that the rest stayed acceptable.

This tutorial presents a two-stage workflow: use Flare for inexpensive iteration on the initial direction, then use Sunburst for a preservation-aware edit and acceptance gate. Ace Data Cloud’s product overview describes Flare as the speed-oriented option and Sunburst as the option for detail and consistency in continued editing. Treat that as a routing heuristic, not a promise that either model will pass every edit on the first attempt.

Disclosure: This article was prepared for an Ace Data Cloud promotional task and is based on Ace Data Cloud’s public product and API documentation. The sample was written with AI assistance, reviewed and adapted for DEV, and was not executed for this article. I am not presenting the linked source authors’ experience as my own.

Why a preservation contract beats a longer prompt

“Replace the background with a workshop” is underspecified. A model may also reinterpret the object, shadows, crop, or typography. Instead, represent the request as two lists:

{
  "change": ["replace the background with a clean electronics workshop"],
  "preserve": [
    "device silhouette",
    "front-panel text and logo",
    "camera angle and crop",
    "blue status LED",
    "contact shadow under the device"
  ]
}
Enter fullscreen mode Exit fullscreen mode

This contract has three benefits. It creates a better edit instruction, gives reviewers a stable checklist, and produces structured metadata that can be stored with every output. It does not make generative editing pixel-locked; the public product article explicitly warns that an edit can reinterpret pixels, especially around text, reflections, occlusion, and poses.

Stage 1: generate a candidate

The public Images Generations API documentation exposes POST /openai/images/generations. The following JavaScript is a minimal, unexecuted example. Use a server-side environment variable—never ship the token in browser code.

const API = "https://api.acedata.cloud";
const token = process.env.ACE_API_TOKEN; // placeholder value in your environment

async function call(path, body) {
  const response = await fetch(`${API}${path}`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${token}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify(body)
  });

  const payload = await response.json().catch(() => ({}));
  if (!response.ok) {
    throw new Error(`image_api_${response.status}: ${JSON.stringify(payload)}`);
  }
  return payload;
}

const draft = await call("/openai/images/generations", {
  model: "gpt-image-2.6-flare",
  prompt: "Studio product photo of a compact network appliance, front three-quarter view, dark blue status LED, neutral seamless background",
  size: "1536x1024",
  quality: "low",
  n: 1,
  output_format: "png",
  response_format: "url"
});
Enter fullscreen mode Exit fullscreen mode

Use an explicit WIDTHxHEIGHT value when dimensions matter. The current docs accept auto, but deterministic application layouts benefit from an explicit canvas. Also validate n before making the request: the documented range is 1–10, while base64 output supports only one image. URL output is easier to queue and inspect, but your system should copy accepted results into storage you control rather than assuming a returned URL is permanent.

Stage 2: edit with explicit invariants

After a human or automated selector approves the composition, pass its URL to the Images Edits API. JSON requests accept HTTPS image URLs; direct file bytes require multipart form data.

const preserve = [
  "device silhouette",
  "front-panel text and logo",
  "camera angle and crop",
  "blue status LED",
  "contact shadow under the device"
];

const edited = await call("/openai/images/edits", {
  model: "gpt-image-2.6-sunburst",
  image: draft.data[0].url,
  prompt: [
    "Replace only the neutral background with a clean electronics workshop.",
    `Preserve exactly: ${preserve.join("; ")}.`,
    "Do not add labels, ports, cables, or text."
  ].join("\n"),
  size: "1536x1024",
  quality: "high",
  n: 1,
  output_format: "png",
  response_format: "url"
});
Enter fullscreen mode Exit fullscreen mode

For tighter localization, GPT Image 2.6’s edit schema also documents a transparent PNG markup annotation layer. It cannot be combined with a mask, GIF output, or prompt rewriter, so reject conflicting options in your validator instead of discovering the conflict after a paid request.

Add an acceptance gate

A successful HTTP response is not the same as an acceptable asset. Store a manifest beside each candidate:

const manifest = {
  sourceUrl: draft.data[0].url,
  resultUrl: edited.data[0].url,
  model: "gpt-image-2.6-sunburst",
  changed: ["background"],
  preserved: Object.fromEntries(preserve.map(item => [item, "pending"])),
  decision: "needs_review",
  createdAt: new Date().toISOString()
};
Enter fullscreen mode Exit fullscreen mode

Your review UI can change each pending value to pass or fail. Do not automatically retry every failure. Classify it first:

  • Transport failure: retry with exponential backoff and an idempotency record in your own job table.
  • Invalid input: stop and return a field-level error; retries waste time.
  • Preservation failure: revise the instruction or add markup, while retaining the original approved source.
  • Policy rejection: record the reason and require a changed request; do not loop.
  • Unknown result after timeout: query your job record or recent task state before submitting again, preventing duplicate work.

Promote an output only when every required invariant passes. Keep the rejected candidate and prompt for debugging, but never overwrite the last approved asset.

Where GIF fits—and where it does not

Both GPT Image 2.6 Flare and Sunburst document native gif output with frame_count from 2–16 and frame_duration_ms. That is useful for lightweight character reactions, sticker prototypes, or UI demonstrations; Ace Data Cloud Studio offers a no-code route for exploring such assets. However, the docs recommend a separate 512×512 GIF workflow, and static-image 4K presets must not be presented as 4K GIF support. Keep animated output in its own validation branch for dimensions, timing, loop quality, and character consistency.

The larger lesson is simple: model choice matters, but workflow design matters more. Separate exploration from controlled editing, turn “do not change this” into stored acceptance criteria, and make retries depend on error class. That converts GPT Image 2.6 from a prompt demo into an auditable image pipeline.

Sources: GPT Image 2.6 launch and editing overview, generation API, and editing API.

Top comments (0)