Skip to main content
POST
/
v1
/
images
/
edits
Create image edit
curl --request POST \
  --url https://api.getinfinityblue.com/v1/images/edits \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "prompt": "<string>",
  "image": "<string>",
  "images": [
    "<string>"
  ],
  "n": 1,
  "size": "<string>",
  "response_format": "b64_json",
  "output_compression": 50,
  "mask": "<string>",
  "input_image_mask": "<string>",
  "input_fidelity": "<string>",
  "user": "<string>"
}
'
{
  "created": 123,
  "data": [
    {
      "b64_json": "<string>",
      "url": "<string>"
    }
  ],
  "usage": {
    "total_tokens": 123,
    "input_tokens": 123,
    "output_tokens": 123,
    "input_tokens_details": {
      "text_tokens": 123,
      "image_tokens": 123
    }
  }
}

Multiple reference images

Pass 1–16 additional reference images via the images field (URL, base64, or File ID) alongside the primary image to enable multi-reference generation.

Request formats

Two request formats are supported:
  • multipart/form-data: Upload images as files
  • application/json: Pass images as base64 data URLs (e.g. data:image/jpeg;base64,...)

Mask fields

  • The mask and input_image_mask parameters are accepted but currently have no effect — edits are always applied to the entire image. For partial editing, consider compositing on the client side.

Output size

It is recommended to explicitly pass the size parameter for predictable output dimensions. Without size, the output dimensions may vary depending on the input images.

gpt-image-2 parameters

ParameterNotes
images (multi-reference)Supports 1–16 reference images
input_fidelityAuto high-fidelity; the API ignores manual settings

Authorizations

Authorization
string
header
required

Bearer token authentication, format: Authorization: Bearer sk-xxxxxx. Get your API key in the console.

Body

Image edit request body (JSON format). Images are passed as base64 data URLs (e.g. data:image/jpeg;base64,...) or image URLs.

model
string
required

The image model to use. Pass gpt-image-2. Snapshot versions (e.g. gpt-image-2-2026-04-21) are currently unavailable.

Example:

"gpt-image-2"

prompt
string
required

A text description of the desired edit. Maximum 1,000 characters.

Example:

"Replace the pen tip in the main image with the round soft brush tip from the reference image, keep everything else unchanged"

image
string
required

The primary image. Accepts a base64 data URL (e.g. data:image/jpeg;base64,...) or an image URL.

images
string[]

Additional reference images (1–16 items). Accepts base64 data URLs or image URLs. Use alongside the primary image for multi-reference editing.

n
integer
default:1

The n parameter is not currently supported. Defaults to n=1, returning one image per request. To generate multiple images, call the endpoint in a loop.

Required range: x >= 1
size
string

Size of the output image. Follows the same rules as the generation endpoint; defaults to auto. It is recommended to pass this explicitly for predictable output dimensions.

Examples:

"1024x1024"

"1536x1024"

response_format
enum<string>
default:b64_json

Format in which the generated image is returned. Defaults to b64_json (Base64-encoded data); set to url for a temporary access URL.

Available options:
b64_json,
url
output_format
enum<string>

Output format of the generated image. Defaults to png; options: png, jpeg, webp.

Available options:
png,
jpeg,
webp
output_compression
integer

Output compression quality (0–100). Applies only when output_format is jpeg or webp.

Required range: 0 <= x <= 100
background
enum<string>

Background setting for the generated image. Defaults to auto; supports opaque or auto. gpt-image-2 does not support transparent — passing it returns a 400 error.

Available options:
opaque,
auto
quality
enum<string>

Quality tiers are not currently supported; all requests use the auto level. The parameter is accepted but has no observable difference between levels.

Available options:
low,
medium,
high,
auto
mask
string

Mask image as a base64 data URL. Masking is not currently supported — the parameter is accepted but has no effect; edits are applied to the entire image.

input_image_mask
string

gpt-image-2-specific mask field as a base64 data URL. Masking is not currently supported — the parameter is accepted but has no effect; edits are applied to the entire image.

input_fidelity
string

Input fidelity setting. For gpt-image-2, high fidelity is enforced automatically; the API ignores this parameter.

user
string

A unique identifier for your end user, useful for abuse monitoring.

Response

Edited image generated successfully

Image generation response body.

created
integer

Unix timestamp (seconds) of creation.

Example:

1713833628

data
object[]

List of generated images.

usage
object

Token usage statistics for the request.