Skip to main content

POST /v1/images/edits

Edit an existing image according to a text prompt. You can send a single base image or multiple, and optionally a mask.

  • Method: POST
  • Path: /v1/images/edits
  • Auth: Bearer token in Authorization header
  • Content-Type: multipart/form-data

Request parameters

  • model (string, required): Image editing model.
  • prompt (string, required, 1..32000): Instructions for the edit.
  • background (string, optional): Background control (provider-specific).
  • mask (binary | null, optional): PNG mask where transparent areas will be replaced.
  • n (integer ≥ 1, optional): Number of images to generate.
  • quality (string, optional): Provider-specific quality preset.
  • response_format (enum: url | b64_json, default url): Output format.
  • size (string, optional): Resolution like 1024x1024.
  • image (binary, optional): Base image file (single).
  • images[] (binary[], optional): Multiple base images.

Note: Provide either image or images[].

Example requests

from openai import OpenAI

client = OpenAI(base_url="https://api.naga.ac/v1", api_key="YOUR_API_KEY")

with open("image.png", "rb") as img:
# Optional: open a mask file
# with open("mask.png", "rb") as m:
resp = client.images.edit(
model="gpt-image-1",
image=img,
prompt="Make the sky more dramatic and add light rays",
size="1024x1024",
n=1,
response_format="url", # or "b64_json"
# mask=m,
)
print(resp.data)

Response

Returns a JSON object with a data array of edited images. Each item contains either:

  • url when response_format = "url", or
  • b64_json when response_format = "b64_json".