Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Create images

Generate one or more images from a text prompt, following the OpenAI Images API wire format.

post
Authorizations
AuthorizationstringRequired

Please provide header value as 'Bearer ' and don't forget to add 'Bearer' HTTP Authorization Scheme before the token.

Body

Request payload for generating images from a text prompt.

modelstring · min: 1Required

ID of the model to use.

Example: black-forest-labs/FLUX.2-klein-4B
promptstring · min: 1Required

Text description of the images to generate.

Example: a white siamese cat
ninteger · min: 1 · max: 10Optional

Number of images to generate, at most 10. A larger value is rejected with a 413. A model may also limit the total pixels one request may produce. See size. When omitted, the model chooses.

sizestringOptional

Size of the generated images as WIDTHxHEIGHT in pixels, for example 1024x1024. A side smaller than 1 or larger than 8192 pixels is rejected with a 413.

Within that, the sizes served are model-specific: a model may accept only a range of sizes, round each side to a step of its own, and limit the pixels one request may produce (n times width times height). A request outside a model's limits is rejected with a 400 whose message states the limit.

When omitted, the model chooses the size.

Example: 1024x1024
output_formatstringOptional

File format of the returned image, for example png or jpeg. Distinct from response_format, which controls how the image is delivered rather than what it is encoded as. Supported formats are model-specific. An unsupported value is rejected with a 400 whose message states the supported formats.

Example: png
response_formatstring · enumOptional

Format of the returned images. b64_json returns the image data inline and is the only format this API serves. Images are not published at a fetchable address, so OpenAI's url is rejected with a 400.

Default: b64_jsonPossible values:
qualitystringOptional

Rendering quality of the generated images. Accepted values and their effect are model-specific.

stylestringOptional

Style of the generated images. Accepted values and their effect are model-specific.

Responses
200

Successful operation.

application/json
post/v1/images/generations
POST /v1/images/generations HTTP/1.1
Host: openai.inference.de-txl.ionos.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 101

{
  "model": "black-forest-labs/FLUX.2-klein-4B",
  "prompt": "a white siamese cat",
  "n": 1,
  "size": "1024x1024"
}
{
  "created": 1700000000,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
    }
  ]
}

Last updated

Was this helpful?