Skip to main content
POST

Supported Models

All three models support text-to-image generation and reference-image generation.

Authorizations

string
required
All endpoints require Bearer Token authentication.Get an API key from API Key Management, then add it to the request header:

Body

string
required
Model name:
  • flux-2-flex
  • flux-2-pro
  • flux-2-max
string
required
Text description of the image to generate or the edit to apply to the reference images.
string
default:"2MP"
Output resolution preset. Supported values:
  • 1MP
  • 2MP (default)
  • 3MP
  • 4MP
Here, 1MP equals 1,048,576 pixels.Legacy aliases remain accepted: 512 / 512P / 1M map to 1MP, 1K / 1024 map to 2MP, 2K / 2048 map to 3MP, and 4K maps to 4MP. Any other value causes the task to fail.The preset determines the output dimensions when size is an aspect ratio.
string
default:"1:1"
Output aspect ratio or pixel dimensions.size also supports auto: when image_urls is provided, the output follows the reference image aspect ratio while keeping the current resolution tier; without a reference image, it uses the default 1:1.Supported size options:
  • 1:1 (default)
  • 4:3
  • 3:4
  • 16:9
  • 9:16
  • 3:2
  • 2:3
  • 21:9
  • 9:21
  • auto - Follow the reference image aspect ratio
You may also provide a pixel string such as 1024x1536. Exact pixel dimensions are subject to the same pixel limits as width and height and take priority over resolution and an aspect ratio.
integer
Exact output width in pixels. It must be provided together with height, and each dimension must be at least 64 pixels. Supplying only one dimension causes the task to fail.A complete width and height pair has the highest priority and overrides resolution and size.
integer
Exact output height in pixels. It must be provided together with width, and each dimension must be at least 64 pixels. Supplying only one dimension causes the task to fail.The output must not exceed 4 MP (width × height ≤ 4,194,304), and the output plus all reference images must not exceed 9 MP in total.
array
Reference images for image-to-image generation. Publicly accessible image URLs and Base64 input are supported.
  • Maximum: 8 images
  • The output plus all reference images must not exceed 9 MP in total
string
default:"jpeg"
Output image encoding. Supported values: jpeg, png, and webp.
integer
default:"1"
Number of images generated per task. The only supported value is 1; submit multiple tasks concurrently if you need multiple images.
integer
Random seed. Reuse the same seed and parameters for reproducible output; omit it to use a random seed.
boolean
default:"false"
Whether to enhance and rewrite the prompt before generation. The default is false. Pass false explicitly to disable prompt rewriting.
integer
default:"2"
Safety tolerance from 0 to 5. Higher values are more permissive.
integer
default:"50"
Sampling steps from 1 to 50. Higher values can improve detail but take longer.This parameter is supported only by flux-2-flex. Do not send it with flux-2-pro or flux-2-max.
number
default:"5.0"
Prompt guidance from 1.5 to 10. Higher values follow the prompt more closely.This parameter is supported only by flux-2-flex. Do not send it with flux-2-pro or flux-2-max.

Resolution Reference Table

Dimension priority is: paired width + height → a pixel-string sizeresolution + aspect-ratio size → the default 2MP + 1:1.

Usage Examples

Text-to-image

Reference-image generation

Exact output dimensions

FLUX.2 Flex controls

Response

integer
Response status code.
array
Submission result array.

Retrieve the Result

Poll GET /v1/tasks/{task_id} until the task reaches completed or failed. See the Task Status API for the complete response schema. Task statuses: A completed task includes one generated image:
The image URL is data.result.images[0].url[0]. Its expiration is defined by the Unix timestamp in data.result.images[0].expires_at; download the image before that time.

Invalid parameters and failed tasks

Invalid model parameters do not produce a synchronous 4xx response. The submission still returns HTTP 200 with a task_id; keep polling until the task becomes failed, then read the specific reason from data.error.message. Failed tasks are fully refunded.
error.code is always task_failed; the specific reason is in error.message.

Notes

  1. Tasks are processed asynchronously. The submission response returns a task_id for polling.
  2. n defaults to 1, which is the only supported value.
  3. Reference images may use publicly accessible image URLs or Base64 input.
  4. Up to 8 reference images are supported, subject to the 9 MP combined input-and-output limit.
  5. Exact output dimensions can be set with a pixel-string size, or with paired width and height. When used, both dimensions must be at least 64 pixels; output is limited to 4 MP.
  6. Result URL expiration is determined by the expires_at value returned in the task response.
  7. Invalid model parameters are returned asynchronously: poll until failed and read data.error.message.