Skip to main content
POST /v1/images/edits uses multipart form-data. Use this endpoint when you want to modify one or more uploaded images rather than generate a new image from scratch.

Common fields

FieldRequiredNotes
modelYesImage editing model
promptYesEdit instruction
imageYesOne uploaded image, or use repeated image fields when supported
maskNoOptional mask to constrain the editable region
response_formatNourl or b64_json

Multipart Example

from pathlib import Path
from openai import OpenAI

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

result = client.images.edit(
    model="gpt-image-1",
    prompt="Replace the background with a rainy cyberpunk street.",
    image=Path("input.png"),
    mask=Path("mask.png"),
    response_format="url",
)

print(result.data[0].url)

Notes

  • at least one image must be provided
  • mask is optional
  • response_format can be url or b64_json
  • prompt and output usage are tracked separately from input image usage

Common mistakes

  • sending JSON instead of multipart form-data
  • forgetting that mask is optional but uploaded images are not
  • using image edits when plain image generation would be simpler

Reference