Generate an image

Generates an image from a text prompt via the image generation router

Authentication

AuthorizationBearer
API key as bearer token in Authorization header

Request

This endpoint expects an object.
modelstringRequired
The image generation model to use
promptstringRequired>=1 character
Text description of the desired image
aspect_ratioenumOptional
Normalized aspect ratio of the generated image. Providers clamp to their supported subset.
backgroundenumOptional

Background treatment. transparent requires an output_format that supports alpha (png or webp).

input_referenceslist of objectsOptional

Reference images to guide image-to-image generation, as base64 data URLs or HTTP(S) URLs.

nintegerOptional

Number of images to generate (1-10). Providers that only support single-image generation reject n > 1.

output_compressionintegerOptional

Compression level (0-100) for webp/jpeg output. Ignored for png and by providers without a compression knob.

output_formatenumOptional
Encoding of the returned image bytes.
providerobjectOptional

Provider-specific passthrough configuration

qualityenumOptional
Rendering quality. Providers without a quality knob ignore this.
resolutionenumOptional

Normalized resolution tier of the generated image. Concrete pixel dimensions are derived per-provider.

seedintegerOptional
If specified, the generation will sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed for all providers.
sizestringOptional

Optional. A convenience shorthand for output dimensions — pass a tier (“2K”, “4K”) or explicit pixels (“2048x2048”) and we normalize it to the right dimensions for the chosen provider. Interchangeable with resolution + aspect_ratio; use those directly for enumerated, per-model discoverable values. Conflicting size + resolution/aspect_ratio is rejected.

streambooleanOptional

If true, partial images are streamed as SSE events as they become available. Only supported by providers with native streaming (currently OpenAI). Non-streaming providers ignore this flag and return a buffered response.

Response

Image generation response
createdinteger

Unix timestamp (seconds) when the image was generated

datalist of objects
Generated images
usageobject
Token and cost usage for the image generation request, when available

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error
500
Internal Server Error
502
Bad Gateway Error