POST /v1/images/generations and NagaAI returns the finished images as links or as inline base64. To change a picture you already have, send it with a prompt to POST /v1/images/edits. Both endpoints follow the OpenAI Images format, so the OpenAI SDK works unchanged.
Generate an image
kinds include image in GET /v1/models, or browse them at naga.ac/models.
The response lists one entry in data per image, and usage reports what NagaAI counted for the bill:
Set the size and count
size is WIDTHxHEIGHT, such as 1536x1024. There is no separate aspect ratio field, so you set the ratio through size. n asks for several images in one request. The limit is limits.max_images on the model’s image_generation operation in GET /v1/models, usually 4.
NagaAI ignores
style, output_format and other fields, so setting them changes nothing.
Choose a link or base64
Withurl, each entry of data holds a link on media.naga.ac to a copy that NagaAI hosts for 24 hours and then deletes. Download the file when you receive the response, or store it in your own bucket. With b64_json, the image bytes come inline as base64 and NagaAI stores nothing.
Vector models such as Ideogram Vector return SVG. A browser that opens the link downloads the file, and an <img> tag still shows it.
Edit an image
POST /v1/images/edits takes a multipart form with the image, a prompt, and an optional mask. A transparent area of the mask marks what the model may repaint.
image_edit operation in GET /v1/models.
Billing
Images are priced per token.usage.output_tokens is what the provider reports for the images it made. When a provider reports nothing, NagaAI counts the model’s published number for the picture’s resolution, for example 1,290 for gemini-2.5-flash-image. A model with no published number counts 2,048 per image. The output_image_token row of pricing in GET /v1/models holds the price per token.
NagaAI checks every prompt with its own moderation before it picks a provider.
Draw with a chat model
Some chat models draw inside a chat request instead. They return the pictures through the chat endpoints, see Images in the answer.Troubleshooting
An image link stops working
NagaAI deletes hosted images 24 hours after it makes them. Download the image on arrival, or ask forb64_json.
400 with size must be in format
The message reads body.size: Value error, size must be in format "{width}x{height}", for example "1024x1024". Write the size as two numbers joined by a lowercase x, with no spaces and no ratio such as 16:9.
400 with Too many images
The message reads Too many images. This model supports up to 4, with the model’s own limit. Lower n, or send several requests.
400 with At least one image must be provided
An edit needs at least one image part. Check that the form is multipart/form-data and that the part is named image or image[].
400 model_not_found
The model does not exist or has no image_generation operation (image_edit for edits). Check its operations in GET /v1/models.