Skip to navigation

Precise edit with Ideogram 4.5

Edit an image with Ideogram 4.5 and get the result back at that image’s exact width and height. Upload the image as image using multipart/form-data, with optional reference_images and a mask. Returns results directly by default; set async or supply a webhook_url to get a generation_id and poll GET /v2/generations/{generation_id}.

Editing the whole image is bounded by 4194304 pixels (the area of a 2048x2048 square), so a larger image comes back scaled down to fit: an 8192x8192 image returns as 2048x2048.

To edit a 4K or 8K image at its full resolution, set context_window to confine the edit to one region, either auto together with a mask, or y_min,x_min,y_max,x_max to name the region yourself. Only that region changes, the rest of the image comes back unchanged, and the result keeps the image’s own width and height at any input size.

curl -X POST https://api.ideogram.ai/v2/image/precise-edit/ideogram-4-5 \
-H "Api-Key: $IDEOGRAM_API_KEY" \
-F image=@photo_8k.png \
-F mask=@mask_8k.png \
-F context_window=auto \
-F prompt="Add round black sunglasses."

Authentication

Api-Keystring

API key for access control. Use in the header with the name “Api-Key”

Query parameters

dry_runbooleanOptionalDefaults to false

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

A request to edit an image with Ideogram 4.5 at that image’s own size. Send it as multipart/form-data with the image to edit and any reference_images and mask.

promptstringRequired1-10000 characters

The edit instruction, in natural language or as a structured JSON prompt. Natural language is automatically converted into a structured prompt; valid structured JSON is used as is.

imagefileRequired

The image to edit, as raw bytes (max 50MB and 67108864 pixels, which 8192x8192 meets exactly; JPEG, PNG, or WEBP). Multipart requests only, and ignored when the same image is also supplied by reference. The output always matches this image’s width and height, and pixels the edit did not meaningfully change are copied exactly from it. Set context_window to keep the full resolution of an image over 4194304 pixels.

reference_imagesfilesOptional

Optional images to guide the edit (max 4, max 50MB each; JPEG, PNG, or WEBP). They are never edited themselves; only image is. Multipart requests only, and ignored when the same references are also supplied by reference. A request with a mask can include at most three, because the mask takes up one reference slot.

maskfileOptional

An optional mask that limits the edit to part of image (max 50MB; JPEG, PNG, or WEBP). Multipart requests only. Black marks the area to edit and white the area to keep; values in between are rounded to the nearer of the two. The mask must have the same width and height as the image being edited and contain both black and white areas. A masked request can include at most three reference images.

context_windowstringOptionalformat: "^(none|auto|[0-9]+,[0-9]+,[0-9]+,[0-9]+)$"Defaults to none

Which region of the image to edit. Set this to keep the full resolution of an image larger than 4194304 pixels. none, the default, edits the whole image, which is bounded by 4194304 pixels (the area of a 2048x2048 square); a larger image comes back scaled down to fit. For example, an 8192x8192 image returns as 2048x2048. auto requires a mask and fits a region around the masked area. If the mask selects more than 4194304 pixels no region fits it, and the request falls back to editing the whole image, scaled down as above. y_min,x_min,y_max,x_max names the region explicitly, by its corners. Rows come first, matching the bbox ordering used elsewhere in this API, and the values are the edited image’s own pixels with the origin at its top-left corner. For example 512,1024,2048,3072 is the region 2048 pixels wide and 1536 tall whose top-left corner is 1024 across and 512 down. The maximum edges are exclusive, so the region measures x_max - x_min by y_max - y_min. It must lie inside the image, measure at least 256px on each side, have an aspect ratio between 1:6 and 6:1, and cover no more than 4194304 pixels. A mask may select only pixels inside it. With auto or an explicit region, only that region changes, the rest of the image comes back unchanged, and the output keeps the image’s own width and height at any input size.

qualityenumOptionalDefaults to medium

The rendering quality to use. very_low is the fastest and cheapest, and high takes longer and is priced higher. This is the only field that affects the price: the size of the image you send does not change it, and neither does context_window.

Allowed values:
seedintegerOptional0-2147483647
Random seed. Set for reproducible generation.
num_imagesintegerOptional1-8Defaults to 1
The number of images to generate.
asyncbooleanOptionalDefaults to false

When false (the default), the request waits until the images are ready and returns them in data. When true, the request returns as soon as it is accepted; poll GET /v2/generations/{generation_id} with the returned generation_id for the result.

webhook_urlstringOptionalformat: "uri"<=2048 characters

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.

Response

The edited images (synchronous requests), or an acknowledgement to poll with GET /v2/generations/{generation_id} (async requests).

generation_kindenum

The kind of generation identified by generation_id. Both kinds can be polled through GET /v2/generations/{generation_id}.

Allowed values:
generation_idstringOptional

URL-safe base64 ID of the generation. Use it to poll GET /v2/generations/{generation_id}.

datalist of objectsOptional

The edited images, in generation order. Present only for synchronous requests (async omitted or false).

seedintegerOptional
The seed that was used, including when you did not set one.

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
422
Unprocessable Entity Error
429
Too Many Requests Error
500
Internal Server Error
503
Service Unavailable Error