GPT-6 Sol & Claude Opus 5.5 are liveGPT-6 Sol at half the price of 5.6 Sol

Object Removal API: Erase Objects From Photos With GPT Image 2

One instruction per object was enough for these three removals. Here is the request code, the results at full size, and where the edit cannot be trusted yet.

Kiki, OmniaKey COO7 min read
On this page

One text instruction per object was enough for the GPT-Image 2 edit endpoint. In three runs on October 28, 2026, we removed a woman with her dog, a blue trash bin and a red kite from one park photo, one sentence each. Each removal left the gap matching its surroundings, and the bench, the trees and the skyline stayed where they were.

The call sends a prompt and one source image and returns a complete new picture. Below is the Python we ran, the three results at full size, and the checks that catch a fill you would rather redo.

What an instruction-based removal does

You send one photo and one sentence. The sentence names the object, says what should replace it, and lists what must stay. The model redraws that area and returns a whole new image, so there is no separate composite step.

The call is the same media task as any other edit on OmniaKey: model gpt-image-2, type image, operation edit, the source photo in the input image field as Base64, and the sentence in the input prompt. Parameters take size as WIDTHxHEIGHT and quality low, medium, high or auto; n must be 1. Both operations are listed on the model page.

Wording is the control. "The small red kite in the sky" gives a different job from "the red thing", and a fill such as "grass and paving stones" decides what occupies the space afterwards. Our GPT Image 2 prompt guide covers sentence order, and the FLUX Kontext alternative guide uses the same kind of instruction on GPT Image 2.

The request

One Python file does the whole job: encode the photo, create the task, poll until it finishes, then download the PNG.

python
import base64
import json
import os
import time
import urllib.request
import uuid

API = "https://api.omniakey.com/v1/media/tasks"
KEY = os.environ["OMNIAKEY_API_KEY"]


def request(method, url, body=None, extra_headers=None):
    headers = {"Authorization": f"Bearer {KEY}", "User-Agent": "omniakey-example/1"}
    data = None
    if body is not None:
        headers["Content-Type"] = "application/json"
        data = json.dumps(body).encode()
    headers.update(extra_headers or {})
    req = urllib.request.Request(url, data=data, headers=headers, method=method)
    with urllib.request.urlopen(req, timeout=120) as resp:
        return json.load(resp)


def edit_image(source_path, prompt, out_path, size="1024x1536", quality="medium"):
    with open(source_path, "rb") as f:
        image = base64.b64encode(f.read()).decode()
    body = {
        "model": "gpt-image-2",
        "type": "image",
        "operation": "edit",
        "input": {"prompt": prompt, "image": {"data": image, "mime_type": "image/jpeg"}},
        "parameters": {"size": size, "quality": quality},
    }
    task = request("POST", API, body, {"Idempotency-Key": str(uuid.uuid4())})["id"]
    for _ in range(150):
        time.sleep(4)
        state = request("GET", f"{API}/{task}")
        if state["status"] not in ("queued", "processing"):
            break
    if state["status"] != "succeeded":
        raise RuntimeError(state.get("error") or state["status"])
    asset_url = state["assets"][0]["url"]  # signed link: valid for about an hour, so download now
    req = urllib.request.Request(asset_url, headers={"User-Agent": "omniakey-example/1"})
    with urllib.request.urlopen(req, timeout=120) as resp, open(out_path, "wb") as f:
        f.write(resp.read())
    return task
if __name__ == "__main__":
    task = edit_image(
        "park-base.jpg",
        "Remove the blue trash bin completely. Fill its spot with grass and paving stones so it matches the surroundings. Keep everything else exactly the same. Photorealistic, no text, no logos.",
        "park-no-bin.png",
        size="1536x1024",
    )
    print("task", task)

We checked the function on October 28, 2026 with a different prompt, a yellow raincoat, on a 1024-pixel JPEG of the base model, and it returned a 1024x1536 PNG.

  • The create call returns HTTP 202 and a task id (OmniaKey image docs, checked October 28, 2026). Poll that task until the status leaves queued or processing; succeeded means the assets are ready, and a failed task carries an error code and message and is not charged.
  • The signed asset URL lapses after about an hour, while the file itself is kept for 24 hours. Download at once with a plain GET that sends no API key.
  • Inline Base64 counts toward a 1 MiB request cap, so shrink a phone photo first.
  • Send a User-Agent header: on October 28, 2026 a request with Python's default one came back HTTP 403, and the header fixed it.
  • Size is explicit, so a landscape photo goes out at 1536x1024. GPT Image always returns an opaque PNG, so read the real dimensions from the downloaded file.

On cost, OpenAI's pricing page lists GPT Image 2 at $8.00 per million image-input tokens and $30.00 per million image-output tokens, with batch rates at half (checked October 28, 2026). The page has no per-image table; its image generation guide has a calculator for one image. OmniaKey's current rate is on the pricing page.

Three removals on one park photo

All four images come from one base frame: a sunny city park path, a wooden bench in the centre, a blue metal trash bin on the left, a woman walking a small brown dog toward the camera, and a small red kite high in a clear sky. Base and results were made at 1536x1024, quality medium, with GPT Image 2 through OmniaKey on October 28, 2026; the scene and the people are synthetic. We sent one sentence per object and ran each once.

RemovedInstruction we sentWhat came back
Woman and dog"Remove the woman and the small brown dog completely. Fill the path and the grass naturally so they match the surroundings. Keep the bench, the blue bin, the trees, the kite and the sky exactly the same. Photorealistic, no text, no logos."Woman and dog gone; path and grass refilled; bench, bin, trees, kite and sky kept
Blue bin"Remove the blue trash bin completely. Fill its spot with grass and paving stones so it matches the surroundings. Keep everything else exactly the same. Photorealistic, no text, no logos."Bin gone; its spot filled with grass and paving; the woman and the dog stayed
Red kite"Remove the small red kite from the sky. Keep the sky natural and everything else exactly the same. Photorealistic, no text, no logos."Kite gone; sky natural; the rest of the frame unchanged
Four tiles: the original park path, then the same frame with the woman and dog removed, the bin removed and the kite removed
Original and three separate removals from the same photo. Each tile changes one thing.

Generated with GPT-Image 2 via the OmniaKey API on October 28, 2026, size 1536x1024, quality medium.

The second tile loses the woman and the dog while the path and grass close behind them, and the bench, bin, trees, kite and skyline stay. The third takes out the bin and rebuilds its spot with grass and paving, with the woman and dog still in frame. The fourth clears the kite from an otherwise unchanged sky.

What to check after each removal

Read every tile at actual size before you ship a removal.

  • The edge of the fill and the rest of the frame. New grass, paving or path texture meets the old somewhere, and the model redraws the whole picture, so compare that seam and a margin around the object with the source photo; a soft, repeating or smeared patch shows there first.
  • Anything that touched the object. A leash, a shadow or a reflection has to be rebuilt along with it.
  • The keep list, item by item. Removal 1 kept the bench, bin, trees, kite and sky; removal 2 kept the woman and the dog. Name each item and then look for it.

Ship a removal when the fill holds up at actual size and every item on the keep list is still in place. When a fill reads as a smudge, re-run the same sentence with the material named, for example "grass and paving stones".

What we did not test

We did not test mask input, crowded scenes or very small objects. If your photo has a crowd, a fence line or a thin strap such as a leash, plan a second run and read that edge at full size.

An instruction template

Remove the [object, with the detail that tells it apart] completely. Fill its spot with [material] so it matches the surroundings. Keep [the things that must stay] exactly the same. Photorealistic, no text, no logos.

  • The object, with the detail that tells it apart. "The small red kite in the sky" beats "the kite", and it tells the model which kite you mean when the frame holds several.
  • The fill, in materials. "Grass and paving stones" gives the model something to line up against the surroundings; "remove it" alone leaves the choice to the model.
  • The keep list. Name what must survive: the bench, the blue bin, the trees, the kite, the sky.
  • The style tail. "Photorealistic, no text, no logos" keeps a photo looking like a photo.

For clothing swaps on a person the same shape works with the garment named as the object that changes; the virtual try-on guide walks through that case.

FAQ

Can I remove a person from a photo with an API?

Yes, with a check of the result. In removal 1 the woman and her dog left the frame in one step, and the path and grass were rebuilt behind them.

Does the endpoint take a mask?

The OmniaKey docs describe one source image and a prompt (checked October 28, 2026). They do not describe a mask field, and no mask was tested. You name the object and its position in words instead of painting a region.

The signed link lasts about an hour (OmniaKey docs, checked October 28, 2026), while the file itself is kept for 24 hours. Download as soon as a task succeeds.

Which size should I request?

Pass size as an explicit WIDTHxHEIGHT, such as 1536x1024 for a landscape photo, and read the real dimensions from the downloaded PNG. GPT Image always returns an opaque file, so plan any crop after the download.

Can one instruction remove two objects?

In removal 1, one sentence removed a woman and her dog together. Other pairs stayed untested.

Start from the GPT-Image 2 model page for the parameters, and check current rates before you plan the next removal.

Models in this article

object removalGPT Image 2image editinginpaintingAPI

Related articles

Recent posts