Create an image
Creates images from a text prompt. The response carries one entry per produced image, each holding either a link the gateway hosts or the image bytes inline.
Requires an API key.
model names a model from Naga’s catalog that serves images.generations, and
the gateway selects a provider for it.
Three checks run before a provider is called.
- The prompt is screened by Naga’s own moderation. A flagged prompt returns
403 inappropriate_content, naming the categories that fired, and no provider is called. sizeis checked for shape alone: two runs of digits with anxbetween them. Whether the model can produce that size is the provider’s answer.nis checked against the maximum the selected model declares for itself, where it declares one.
response_format selects which field of every data[] entry is filled. Exactly
one of the two is present on each entry.
url, the default — the gateway stores the bytes the provider returned in its own object store under a freshly minted random name, and responds with the public URL of that copy. The link belongs to Naga and points at the stored copy. The object carries no expiry.b64_json— the image bytes inline, as standard base64. The gateway stores nothing, so the response carries no link to return to later.
The account is charged after the images are delivered, at the model’s published
prices. usage on the response is the gateway’s own count and is the same count
the charge is computed from. Models that price a prompt count it in input
tokens. Produced images are counted in output tokens, using the provider’s
number where it reported one and a flat 2048 per image where it did not. A
request whose images could not be delivered is not charged.
Every response below 200 carries an object under error with a
machine-readable type, a human-readable message, and, where the failure
concerns one field, param. 429 and 503 carry Retry-After with the
seconds to wait.
Authorizations
An account API key. Send it as Authorization: Bearer <key>.
Body
The request body of POST /v1/images/generations.
POST /v1/images/edits asks for the same six fields as multipart form
parts instead, beside the image files themselves, an optional mask and an
optional background. Its prompt is bounded at 32000 characters rather
than at 8192.
The model to generate with, named by its id or by one of its aliases.
A name this gateway does not serve on this route is refused with 400
model_not_found; a name it served and has since retired, with 410
model_deprecated.
What to generate, in words. One to 8192 characters — characters, not
bytes. The prompt is screened by the gateway's own moderation before
the image model is called, and a flagged prompt is refused with 403
inappropriate_content naming the categories that fired.
The provider's quality knob, passed through untouched. The gateway neither checks the value nor holds a menu of accepted ones. What a value means is the serving provider's business, and a provider with no such knob drops it.
The requested image size, written {width}x{height}, as in 1024x1024.
The gateway checks the shape alone: two runs of decimal digits with an
x between them. Any other shape is refused with 400. Whether the model
can produce that particular size is the provider's answer.
How many images to ask for. Absent means one. Less than 1 is refused
with 400, and so is a value above the maximum a model declares for
itself. How many images actually come back is the provider's answer —
data carries what it produced.
Whether each image comes back as a link (url) or as inline base64
(b64_json). url when the key is absent, and the choice is what
decides which field of every data[] entry is filled.
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 of a successful POST /v1/images/generations and of
POST /v1/images/edits — one shape, answered by both routes.
When the gateway rendered this body, in whole seconds since the Unix epoch. The clock is read after the provider has answered, so the value dates the answer rather than the request.
The produced images, in the order the provider returned them — one
entry per image it produced, which need not be the n that was asked
for.
What the request was metered on. Always present, including for a provider that reports no usage of its own: the gateway fills the block from its own counting.