edit-workflow

Replace an image background

Replaces the background of one image from a text prompt while preserving the foreground subject. The foreground mask is detected automatically; callers do not provide a mask.

The request is processed asynchronously. Poll GET /v1/generations/{generation_id} with the returned generation_id until the generation is completed or failed.

Supply exactly one source transport: an existing AssetIdentifier in image_asset_identifier, or raw image bytes in a multipart request. Supplying both or neither is rejected with a 400.

post/v2/image/replace-background/gpt-image-2

Query parameters

dry_runboolean

When true, the request is validated and priced but not run: nothing is generated, stored, or billed, and no safety review is performed. The response is a PriceQuote object instead of the usual response for this endpoint. Send exactly the request you would send to generate, so the quote reflects the same options.

Request body

imagestring binary

Raw source-image bytes. JPEG, PNG, WEBP, HEIF, AVIF, GIF, BMP, TIFF, and MPO are supported, up to 50 MB. Multipart requests only.

promptstring required

Plain-language description of the desired new background.

quality'low' | 'medium' | 'high'

The quality tier for the edit. Higher tiers may improve detail and take longer to complete.

num_imagesinteger

The number of images to generate.

privateboolean

If true, the user is requesting private generation. If omitted, this defaults to the user's plan entitlement. Enterprise generations are always private.

webhook_urlstring uri

HTTPS URL that Ideogram delivers the generated result to. Ideogram sends a JSON POST to this URL once all images for the request have finished generating. The body mirrors the synchronous generate response: request_id, created, and a data array containing every generated image (url, prompt, resolution, seed, is_image_safe). Each delivery is signed with Ed25519 and verifiable against the public keys at https://api.ideogram.ai/v1/.well-known/jwks.json. Must be HTTPS; private and loopback hosts and the cloud metadata service are rejected.

Example request

{
  "image_asset_identifier": {
    "asset_type": "RESPONSE",
    "asset_id": "7uS_VESkRI6O3-sVgHQp_A"
  },
  "webhook_url": "https://api.example.com/webhooks/ideogram"
}

Response

Background replacement accepted for asynchronous processing.

generation_idstring required

URL-safe base64 ID accepted by the generation polling endpoint.

Example response

{
  "generation_id": "generation_id"
}

Changes

Changed in 4 of the 33 revisions of this API.8213

    • ○

      added the optional property to the response with the status

      response-optional-property-added

    • ○

      added the optional property to the response with the status

      response-optional-property-added

    • ○

      added the optional property to the response with the status

      response-optional-property-added

    • ○

      added the optional property to the response with the status

      response-optional-property-added

  • cdaa218128ba22See the full diff
    • ▲

      added to the request property allOf list (media type: multipart/form-data)

      request-property-all-of-added

    • ▲

      added to the request property allOf list (media type: application/json)

      request-property-all-of-added

    • ●

      removed from the request property allOf list (media type: multipart/form-data)

      request-property-all-of-removed

    • ●

      removed from the request property allOf list (media type: application/json)

      request-property-all-of-removed

    This revision also has 1 change that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog

  • 4e95197be44a68See the full diff
    • ▲

      removed the enum value HIGH of the request property / (media type: multipart/form-data)

      request-property-enum-value-removed

    • ▲

      removed the enum value HIGH of the request property / (media type: application/json)

      request-property-enum-value-removed

    • ▲

      removed the enum value LOW of the request property / (media type: multipart/form-data)

      request-property-enum-value-removed

    • ▲

      removed the enum value LOW of the request property / (media type: application/json)

      request-property-enum-value-removed

    • ▲

      removed the enum value MEDIUM of the request property / (media type: multipart/form-data)

      request-property-enum-value-removed

    • ▲

      removed the enum value MEDIUM of the request property / (media type: application/json)

      request-property-enum-value-removed

    • ○

      the request property default value changed from HIGH to high (media type: multipart/form-data)

      request-property-default-value-changed

    • ○

      the request property default value changed from HIGH to high (media type: application/json)

      request-property-default-value-changed

    • ○

      added the new high enum value to the request property / (media type: multipart/form-data)

      request-property-enum-value-added

    • ○

      added the new high enum value to the request property / (media type: application/json)

      request-property-enum-value-added

    • ○

      added the new low enum value to the request property / (media type: multipart/form-data)

      request-property-enum-value-added

    • ○

      added the new low enum value to the request property / (media type: application/json)

      request-property-enum-value-added

    • ○

      added the new medium enum value to the request property / (media type: multipart/form-data)

      request-property-enum-value-added

    • ○

      added the new medium enum value to the request property / (media type: application/json)

      request-property-enum-value-added

    This revision also has 13 changes that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog

    • ○

      endpoint added

      endpoint-added

    This revision also has 13 changes that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog