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

Generate an image using a model

Generate an image using a model in a format that is compatible with the OpenAI API

post
Authorizations
AuthorizationstringRequired

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

Body
modelstringRequired

ID of the model to use. Please check /v1/models for available models

promptstringRequired

The prompt to generate images from

ninteger · min: 1 · max: 10Optional

The number of images to generate. Defaults to 1. Each model also limits the total pixels one request may produce, n times width times height: 4194304 for FLUX.1-schnell (for example one 2048x2048 image or four 1024x1024 images) and 12582912 for FLUX.2-klein-4B (for example three 2048x2048 images). A request over that total-pixel limit is rejected with a 400 Bad Request; a width or height above 8192 pixels is rejected with a 413 Payload Too Large.

Default: 1
sizestringOptional

The size of the image to generate, in "widthxheight" format, for example "1024x1024". Defaults to "1024x1024". Width and height from 64 through 2048 pixels (inclusive) are accepted, and each side is rounded down to the nearest multiple of 16: "1000x1000" returns a 992x992 image. The bounds are checked before rounding, so a side outside them is rejected, not rounded into range. Values from 2049 through 8192 are rejected with a 400 Bad Request; a width or height above 8192 pixels is rejected with a 413 Payload Too Large.

Default: 1024x1024Pattern: ^\d+x\d+$
output_formatstringOptional

The file format of the generated image. Currently png (the default), jpeg, jpg (the same as jpeg) and webp; more formats may be added. A value that is not supported is rejected with a 400 Bad Request.

Default: png
userstringOptional

A unique identifier representing your end-user

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: 115

{
  "model": "black-forest-labs/FLUX.2-klein-4B",
  "prompt": "A beautiful sunset over the ocean",
  "n": 1,
  "size": "1024x1024"
}
{
  "created": 1,
  "data": [
    {
      "url": "text",
      "b64_json": "text",
      "revised_prompt": "text"
    }
  ]
}

Last updated

Was this helpful?