curl https://api.naga.ac/v1/images/generations \
-H "Authorization: Bearer $NAGA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "A watercolour fox in a snowy forest",
"size": "1024x1024",
"n": 1
}'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.generate(
model="gpt-image-1",
prompt="A watercolour fox in a snowy forest",
size="1024x1024",
n=1,
)
print(result)
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.generate({
model: "gpt-image-1",
prompt: "A watercolour fox in a snowy forest",
size: "1024x1024",
n: 1,
});
console.log(result);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.naga.ac/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-1\",\n \"prompt\": \"A watercolour fox in a snowy forest\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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/9f2c4a1b.png"
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 1024,
"total_tokens": 1036
}
}{
"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>"
}
}Create an image
Creates images from a text prompt and charges the account for what it counted. Requires an API key. /v1/images/edits changes images that were uploaded instead.
curl https://api.naga.ac/v1/images/generations \
-H "Authorization: Bearer $NAGA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "A watercolour fox in a snowy forest",
"size": "1024x1024",
"n": 1
}'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.generate(
model="gpt-image-1",
prompt="A watercolour fox in a snowy forest",
size="1024x1024",
n=1,
)
print(result)
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.generate({
model: "gpt-image-1",
prompt: "A watercolour fox in a snowy forest",
size: "1024x1024",
n: 1,
});
console.log(result);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.naga.ac/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"gpt-image-1\",\n \"prompt\": \"A watercolour fox in a snowy forest\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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/9f2c4a1b.png"
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 1024,
"total_tokens": 1036
}
}{
"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 request body of POST /v1/images/generations.
The model to generate with, named by its id or alias.
What to generate, in words. One to 8192 characters, and moderation screens it first.
The provider's quality knob, passed through unchecked. A provider without one drops it.
The requested image size, written {width}x{height}; any other shape draws a refusal.
How many images to ask for. Absent means one; a value above what the model declares draws a refusal.
Whether each image comes back as a link (url) or as inline base64 (b64_json).
url, b64_json Response
The produced images. Each entry of data carries either a link the gateway hosts or the bytes inline, whichever response_format asked for. usage carries the count the charge was computed from.
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.