Generate an image using a model
Generate an image using a model in a format that is compatible with the OpenAI API
Please provide header value as 'Bearer ' and don't forget to add 'Bearer' HTTP Authorization Scheme before the token.
ID of the model to use. Please check /v1/models for available models
The prompt to generate images from
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.
1The 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.
1024x1024Pattern: ^\d+x\d+$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.
pngA unique identifier representing your end-user
Successful operation
The request was rejected before it reached a model. The message names the field at fault.
The request body, an inline base64 media payload, or the number of content parts in a single message, query, or document exceeds a documented limit, or a requested image's width or height is above the maximum supported size. Pass large media as a remote http(s) URL instead of inline base64 - a remote URL is fetched directly by the model and does not count against the request body size.
Rate limit exceeded. This response carries no Retry-After header, so back off exponentially and watch X-RateLimit-Remaining-Requests on successful responses to slow down before reaching the limit. Limits are contract-specific.
The request failed on our side. It may or may not have been carried out, so a retry is safe for idempotent calls.
The platform is temporarily overloaded and is shedding load to stay stable. Retry after the number of seconds indicated by the Retry-After header. This is unrelated to your contract's rate limits.
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?