Skip to main content
POST
openai-python

Authorizations

Authorization
string
header
required

An account API key. Send it as Authorization: Bearer <key>.

Body

application/json

The request body of POST /v1/images/generations.

model
string
required

The model to generate with, named by its id or alias.

prompt
string
required

What to generate, in words. One to 8192 characters, and moderation screens it first.

models
string[] | null

Fallback models, tried in order when model cannot answer: none of its providers served it, or the request does not fit it. At most 3, and only the model that answered is billed. A NagaAI extension in OpenRouter's shape.

Maximum array length: 3
routing
object

How NagaAI picks the providers for this request: max_price removes the dearer ones and can fail the request. Takes no strategy. A NagaAI extension.

quality
string | null

The provider's quality knob, passed through unchecked. A provider without one drops it.

size
string | null

The requested image size, written {width}x{height}; any other shape draws a refusal.

n
integer<int64> | null

How many images to ask for. Absent means one; a value above what the model declares draws a refusal.

response_format
enum<string>
default:url

Whether each image comes back as a link (url) or as inline base64 (b64_json).

Available options:
url,
b64_json
stream
boolean | null

Whether the answer comes as server-sent events instead of one JSON body: one image_generation.completed event per image, carrying it as base64 whatever response_format says.

partial_images
integer<int64> | null

How many partial images to stream before the final one, 0 to 3, with stream only. As OpenAI documents, fewer may arrive than asked; NagaAI sends the final image as soon as the provider finishes, without partials.

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. With stream, text/event-stream carries one image_generation.completed event per image instead, usage on the last.

The body both image routes answer with.

created
integer<int64>
required

When the gateway rendered this body, in seconds since the Unix epoch.

data
object[]
required

The produced images, in the order the provider returned them.

usage
object
required

What the gateway metered, filling in where the provider reported nothing.