Skip to content
Эта страница пока недоступна на вашем языке, поэтому она отображается на английском.

FLUX.2 Image Generation

Submit asynchronous FLUX.2 text-to-image or reference-image generation tasks. The API returns a task ID; poll the task endpoint for the generated image.

Вся документация
POST/v1/images/generations

Примеры запросов

curl --request POST \
  --url https://api.apisea.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flux-2-pro",
    "prompt": "A blue cat sitting on the grass",
    "resolution": "2MP",
    "size": "16:9",
    "output_format": "jpeg"
  }'

Supported Models

ModelDescription
flux-2-flexFine-grained generation with adjustable sampling steps and guidance.
flux-2-proBalanced quality and speed for general-purpose production workflows.
flux-2-maxHighest-quality FLUX.2 model for maximum detail.

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

Authorizations

Authorizationstringrequired

All endpoints require Bearer Token authentication.

Get an API key from API Key Management, then add it to the request header:

text
Authorization: Bearer YOUR_API_KEY

Body

modelstringrequired

Model name:

  • flux-2-flex
  • flux-2-pro
  • flux-2-max
nsfw_checkbooleandefault: false

Whether to run content moderation before submitting the image task.

  • true: use omni-moderation-latest to review prompts and input images
  • false or omitted: do not send a moderation request, adding no moderation cost or latency (default)
promptstringrequired

Text description of the image to generate or the edit to apply to the reference images.

resolutionstringdefault: 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.

sizestringdefault: 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.

widthinteger

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.

heightinteger

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.

image_urlsarray

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
output_formatstringdefault: jpeg

Output image encoding. Supported values: jpeg, png, and webp.

nintegerdefault: 1

Number of images generated per task. The only supported value is 1; submit multiple tasks concurrently if you need multiple images.

seedinteger

Random seed. Reuse the same seed and parameters for reproducible output; omit it to use a random seed.

prompt_upsamplingbooleandefault: false

Whether to enhance and rewrite the prompt before generation. The default is false. Pass false explicitly to disable prompt rewriting.

safety_toleranceintegerdefault: 2

Safety tolerance from 0 to 5. Higher values are more permissive.

stepsintegerdefault: 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.

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

Aspect ratio1MP2MP (default)3MP4MP
1:11024×10241440×14401536×15362048×2048
4:31152×8641664×12481824×13602336×1760
3:4864×11521248×16641360×18241760×2336
16:91344×7521920×10722048×11522720×1536
9:16752×13441072×19201152×20481536×2720
3:21248×8321728×11521872×12482496×1664
2:3832×12481152×17281248×18721664×2496
21:91504×6402176×9282304×9923072×1312
9:21640×1504928×2176992×23041312×3072

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

Usage Examples

Text-to-image

json
{
  "model": "flux-2-pro",
  "prompt": "A cinematic city at night with neon reflections on wet streets",
  "resolution": "1MP",
  "size": "16:9"
}

Reference-image generation

json
{
  "model": "flux-2-pro",
  "prompt": "Place the person from the first image in the scene from the second image and match the lighting",
  "image_urls": [
    "https://example.com/person.jpg",
    "https://example.com/scene.jpg"
  ],
  "resolution": "2MP",
  "output_format": "webp"
}

Exact output dimensions

json
{
  "model": "flux-2-max",
  "prompt": "A highly detailed botanical illustration",
  "width": 1024,
  "height": 1536
}

FLUX.2 Flex controls

json
{
  "model": "flux-2-flex",
  "prompt": "A minimalist poster with the headline SUMMER SALE and the subheading 50% OFF",
  "resolution": "3MP",
  "size": "3:4",
  "steps": 50,
  "guidance": 6.5
}

Response

codeinteger

Response status code.

dataarray

Submission result array.

Properties

statusstring

Submission status. A successfully accepted task returns submitted.

task_idstring

Unique task identifier. Use it to poll the task endpoint.

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:

StatusMeaning
submitted / pendingAccepted or queued; continue polling.
processingImage generation is in progress; continue polling.
completedGeneration succeeded; the image is available in result.images.
failedGeneration failed; read data.error.message. The task is fully refunded.

A completed task includes one generated image:

json
{
  "code": 200,
  "data": {
    "id": "task_01KFG5BBFNK1YQDTJDZY0P0QT2",
    "status": "completed",
    "progress": 100,
    "result": {
      "images": [
        {
          "url": ["https://cdn.example.com/f/image/xxxxxxxx-flux-2.jpeg"],
          "expires_at": 1785220083
        }
      ]
    }
  }
}

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.

json
{
  "code": 200,
  "data": {
    "status": "failed",
    "error": {
      "type": "task_failed",
      "code": "task_failed",
      "message": "`steps` must be between 1 and 50 (got 0)"
    }
  }
}

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.

Ответы

{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KFG5BBFNK1YQDTJDZY0P0QT2"
    }
  ]
}

Нашли ошибку в документации? Напишите на support@apisea.ai.