curl https://api.naga.ac/v1/images/edits \
-H "Authorization: Bearer $NAGA_API_KEY" \
-F 'model=gpt-image-1' \
-F 'prompt=Put a red scarf on the fox' \
-F 'image=@fox.png'import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NAGA_API_KEY"],
base_url="https://api.naga.ac/v1",
)
result = client.images.edit(
model="gpt-image-1",
prompt="Put a red scarf on the fox",
image=[open("fox.png", "rb")],
)
print(result)
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NAGA_API_KEY,
baseURL: "https://api.naga.ac/v1",
});
const result = await client.images.edit({
model: "gpt-image-1",
prompt: "Put a red scarf on the fox",
image: [fs.createReadStream("fox.png")],
});
console.log(result);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.naga.ac/v1/images/edits"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\ngpt-image-1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nPut a red scarf on the fox\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"\r\n\r\nfox.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask.1\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"created": 1774000000,
"data": [
{
"url": "https://cdn.naga.ac/images/1d7e8b02.png"
}
],
"usage": {
"input_tokens": 274,
"output_tokens": 1024,
"total_tokens": 1298
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_api_key",
"message": "The provided API key is invalid. Please ensure your API key is correct and active. You can find more information about obtaining a key on our website: https://naga.ac If you just created this key, wait a few minutes and try again."
}
}{
"error": {
"type": "insufficient_quota",
"message": "More credits required to process this request. Visit https://naga.ac/dashboard/credits to add credits."
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "rate_limit_exceeded",
"message": "Rate limit reached. Please try again in 3s."
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}Edit an image
Edits uploaded images against a text prompt and charges the account for what it counted. Requires an API key. /v1/images/generations draws from a prompt alone.
curl https://api.naga.ac/v1/images/edits \
-H "Authorization: Bearer $NAGA_API_KEY" \
-F 'model=gpt-image-1' \
-F 'prompt=Put a red scarf on the fox' \
-F 'image=@fox.png'import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NAGA_API_KEY"],
base_url="https://api.naga.ac/v1",
)
result = client.images.edit(
model="gpt-image-1",
prompt="Put a red scarf on the fox",
image=[open("fox.png", "rb")],
)
print(result)
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NAGA_API_KEY,
baseURL: "https://api.naga.ac/v1",
});
const result = await client.images.edit({
model: "gpt-image-1",
prompt: "Put a red scarf on the fox",
image: [fs.createReadStream("fox.png")],
});
console.log(result);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.naga.ac/v1/images/edits"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\ngpt-image-1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nPut a red scarf on the fox\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"\r\n\r\nfox.png\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image.items\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask.0\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mask.1\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n{\r\n \"fileName\": \"example-file\"\r\n}\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"created": 1774000000,
"data": [
{
"url": "https://cdn.naga.ac/images/1d7e8b02.png"
}
],
"usage": {
"input_tokens": 274,
"output_tokens": 1024,
"total_tokens": 1298
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_api_key",
"message": "The provided API key is invalid. Please ensure your API key is correct and active. You can find more information about obtaining a key on our website: https://naga.ac If you just created this key, wait a few minutes and try again."
}
}{
"error": {
"type": "insufficient_quota",
"message": "More credits required to process this request. Visit https://naga.ac/dashboard/credits to add credits."
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "rate_limit_exceeded",
"message": "Rate limit reached. Please try again in 3s."
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}Authorizations
An account API key. Send it as Authorization: Bearer <key>.
Body
The images to edit, one per part named image, beside the prompt to edit them against and the fields POST /v1/images/generations takes in JSON.
The multipart/form-data body of POST /v1/images/edits — the images to edit, the prompt to edit them against, and the fields POST /v1/images/generations takes in JSON.
The model to edit with, named by its id or alias.
What to change, in words. One to 32000 characters.
The images to edit, one per part named image; image[] merges into the same list.
One uploaded image, as the bytes of the file itself.
The provider's background knob, passed through unchecked. A provider without one drops it.
A single image whose transparent area marks what the model may repaint.
How many images to ask for. Absent means one; a value above what the model declares draws a refusal.
The provider's quality knob, passed through unchecked. A provider without one drops it.
Whether each image comes back as a link (url) or as inline base64 (b64_json).
url, b64_json The requested image size, written {width}x{height}; any other shape draws a refusal.
Response
The edited images, in the same body POST /v1/images/generations answers with.
The body both image routes answer with.
When the gateway rendered this body, in seconds since the Unix epoch.
What the gateway metered, filling in where the provider reported nothing.
Hide child attributes
Hide child attributes
Output tokens charged for the produced images, 2048 apiece where the provider counted none.
The sum of input_tokens and output_tokens.
Input tokens charged for. Zero on a model that prices no input text token.