Realtime TTS-2 is live. Built for realtime conversation that feels human. Read the Realtime TTS-2 announcement

Images

Create image

Generate images from a text prompt with a model served on the Images API

POST/v1/images/generations

Generate images from a text prompt. The response carries every image as base64 in data[].b64_json. This endpoint follows the OpenAI Images API and works with client.images.generate in the OpenAI SDK.

It serves the image models whose endpoints in the List models API contain /v1/images/generations. Other image models, including some that output only images, generate images through chat completions instead. Each model takes its own options, and the API rejects an option the model does not take with 400. See Generate and edit images with the Images API for options, errors and billing, and OpenAI Images API compatibility for how each field is handled.

Authorizations

Authorizationstringrequired

Your authentication credentials. For Basic authentication, populate Basic $INWORLD_API_KEY.

Body

application/json

modelstringrequired

An Images API model ID: a model whose endpoints in the List models API contain this route.

promptstringrequired

What to generate. It has no length limit of its own: the request body is limited to 512 KiB, and the model can reject a longer prompt than it accepts.

nintegerdefault: 1

How many images to return, from 1 to the model's maximum. A larger value returns 400 with the maximum in the message. meta/muse-image-1.0 returns up to 10.

sizestring

auto or WIDTHxHEIGHT, on models that take it. The model chooses the exact pixel dimensions and can treat the value as a shape: a 1024x1024 request to meta/muse-image-1.0 returned 1600x1600 images.

output_formatstring

The file format of the returned images, on models that take it, with the values each model allows. meta/muse-image-1.0 takes png, jpeg or webp, and returns webp when it is left out.

qualitystring

Image quality, on models that take it; rejected (400) on others, including meta/muse-image-1.0.

backgroundstring

Background, such as transparent or opaque, on models that take it; rejected (400) on others, including meta/muse-image-1.0.

moderationstring

Moderation level, on models that take it; rejected (400) on others, including meta/muse-image-1.0.

response_formatenum<string>default: "b64_json"

Images are always returned as base64 in b64_json. url is rejected (400).

Available options:b64_json

streambooleandefault: false

Return the result as server-sent events. The API sends one completed event per image once all images are ready; it sends no partial images.

userstring

Accepted for compatibility and ignored: it is not sent to the model.

safety_identifierstring

Accepted for compatibility and ignored: it is not sent to the model.

Response

200 - application/json

createdintegerrequired

When the images were created, in Unix seconds.

dataobject[]required

One entry per image returned.

Show child attributes

b64_jsonstringrequired

The image file, base64-encoded.

revised_promptstring

The prompt the model used, when it rewrote yours.

output_formatstring

The file format of every image in data, such as png, jpeg or webp.

sizestring

The size of the returned images when the model reports it; otherwise the size you asked for. Read the dimensions from the image file if you depend on them.

backgroundstring

The images' background, when known.

qualitystring

The images' quality, when known.

usageobject

Token counts the model reports, for information only: the Images API bills per image returned, not per token. Omitted when the model reports none.

Show child attributes

input_tokensinteger

output_tokensinteger

total_tokensinteger

input_tokens_detailsobject

Present only when the model reports it.

Show child attributes

text_tokensinteger

image_tokensinteger

output_tokens_detailsobject

Present only when the model reports it.

Show child attributes

text_tokensinteger

image_tokensinteger