POST /v1/images/edits takes a multipart form with one or more images, a prompt and an optional mask.
The model must list
images.edits in supported_endpoints. The response has the same shape as a generation.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Change existing images with a prompt and an optional mask through POST /v1/images/edits.
POST /v1/images/edits takes a multipart form with one or more images, a prompt and an optional mask.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.naga.ac/v1", api_key=os.environ["NAGAAI_API_KEY"])
with open("boat.png", "rb") as image:
result = client.images.edit(
model="gpt-image-2",
image=image,
prompt="Make the boat blue and add a small flag",
size="1024x1024",
)
print(result.data[0].url)
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.naga.ac/v1", apiKey: process.env.NAGAAI_API_KEY });
const result = await client.images.edit({
model: "gpt-image-2",
image: fs.createReadStream("boat.png"),
prompt: "Make the boat blue and add a small flag",
size: "1024x1024",
});
console.log(result.data[0].url);
curl https://api.naga.ac/v1/images/edits \
-H "Authorization: Bearer $NAGAAI_API_KEY" \
-F model=gpt-image-2 \
-F image=@boat.png \
-F prompt="Make the boat blue and add a small flag" \
-F size=1024x1024
| Field | Notes |
|---|---|
image | The image to change. Models that combine images take several |
mask | A PNG whose transparent area marks what to change |
prompt | Up to 32,000 characters |
background, quality, n, size, response_format | As in Images |
images.edits in supported_endpoints. The response has the same shape as a generation.