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 Authorizationheader
- 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 Request
- Python
- Node.js
- cURL
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)
import OpenAI from "openai";
import fs from "fs";
const client = new OpenAI({ baseURL: "https://api.naga.ac/v1", apiKey: "YOUR_API_KEY" });
const resp = await client.images.edit({
  model: "gpt-image-1",
  image: fs.createReadStream("image.png"),
  // mask: fs.createReadStream("mask.png"), // optional
  prompt: "Make the sky more dramatic and add light rays",
  size: "1024x1024",
  n: 1,
  response_format: "url", // or "b64_json"
});
console.log(resp.data);
curl https://api.naga.ac/v1/images/edits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F image="@image.png" \
  -F prompt="Make the sky more dramatic and add light rays" \
  -F model="gpt-image-1" \
  -F size="1024x1024" \
  -F n=1 \
  -F response_format="url"
Authentication
Provide your key as a Bearer token:
Authorization: Bearer YOUR_API_KEY
Response
Returns a JSON object with a data array of edited images. Each item contains either:
- urlwhen- response_format = "url", or
- b64_jsonwhen- response_format = "b64_json".
Response Fields
- created(integer): Unix timestamp of request creation
- data(array): Array of edited image objects- url(string, optional): Image URL (when- response_format = "url")
- b64_json(string, optional): Base64-encoded image (when- response_format = "b64_json")
- revised_prompt(string, optional): The actual prompt used after any modifications