Перейти к основному содержанию
POST

Обзор

POST /flux/v1/\{model\} генерирует изображение с помощью нативного запроса в формате BFL. По умолчанию запросы выполняются асинхронно. Сохраните id из ответа верхнего уровня, затем опрашивайте GET /flux/v1/get_result с этим ID задачи. Чтобы дождаться изображения в рамках того же запроса, передайте "async": false в теле JSON. Успешный синхронный ответ содержит status: "Ready" и URL изображения в result.sample. API playground включает примеры запросов text-to-image для FLUX.2 Pro, Flex и Max. См. страницу моделей или /v1/models для получения ID моделей и сведений об их доступности для аккаунта.

Поля запроса

Начните с prompt, width, height и output_format. Можно также передать seed; завершённый результат может содержать использованное seed, но одно это поле не обеспечивает воспроизводимость результата. Необязательное поле async определяет способ возврата результата запроса. Для синхронной генерации используйте логическое значение JSON false. Для асинхронной генерации используйте true или не указывайте это поле. Не передавайте строку, например "false". Для редактирования с эталонным изображением передайте публичный HTTPS URL изображения в input_image. Это поле поддерживается для трёх указанных выше моделей FLUX.2. FLUX.2 Pro также принимает второй публичный HTTPS URL в input_image_2; всегда включайте input_image, когда передаёте input_image_2.

Синхронная генерация

Выберите Синхронное преобразование текста в изображение (FLUX.2 Pro) в примерах запросов, чтобы отправить "async": false. Не закрывайте соединение, пока генерируется изображение. В примере используется тайм-аут клиента 300 секунд; это настройка клиента, а не крайний срок завершения. Когда ответ содержит status: "Ready", считайте result.sample напрямую. Опрос результата не требуется. Если запрос завершается ошибкой, обработайте HTTP-ошибку перед чтением результата. Не комбинируйте async: false с webhook_url или webhook_secret. Синхронные запросы возвращают результат напрямую и отклоняют эти поля webhook.

Асинхронная отправка и опрос

Когда async имеет значение true или не указан, ответ на создание возвращает ID задачи, пока генерация продолжается. Используйте его id верхнего уровня с endpoint результатов CometAPI; клиенты не должны зависеть от polling_url, предоставляемого в ответе. Выполняйте опрос, пока endpoint результатов не вернёт status: "Ready". Считайте Error, Failed, Failure, Task not found, Request Moderated и Content Moderated сбоями. Для остальных состояний продолжайте опрос в пределах ограничений повторных попыток и тайм-аутов вашего приложения.
Когда задача готова, result.sample содержит временный URL изображения. Скачайте или перенесите его незамедлительно; не рассчитывайте на фиксированный срок действия.

Авторизации

Authorization
string
header
обязательно

Bearer token authentication. Use your CometAPI key.

Параметры пути

model
string
обязательно

FLUX.2 model ID in the URL path. Check /v1/models or the Models page for account availability.

Тело

application/json
prompt
string
обязательно

Text prompt describing the image or reference-image edit.

Пример:

"A clean editorial photograph of a red ceramic teapot on a pale blue table, soft window light, no text."

async
boolean
по умолчанию:true

Controls whether generation returns asynchronously. Set false to wait for the finished image and read result.sample from the successful response. Set true or omit this field to receive a task ID for polling. Use a JSON boolean, not a string. Do not combine false with webhook_url or webhook_secret.

input_image
string
обязательно if input_image_2 is set

Public HTTPS URL of the first reference image. Replace the example URL with a publicly accessible image. This editing field is available for the FLUX.2 models covered by this reference.

Пример:

"https://your-image-host/reference-one.jpg"

input_image_2
string

Public HTTPS URL of a second reference image for flux-2-pro. Replace the example URL and also send input_image.

Пример:

"https://your-image-host/reference-two.jpg"

seed
integer

Optional seed value. A completed result can report the used seed; that field alone does not establish repeatable output.

width
integer

Requested output width in pixels. Use a dimension supported by the selected model.

Пример:

1280

height
integer

Requested output height in pixels. Use a dimension supported by the selected model.

Пример:

768

output_format
string

Requested output image format supported by the selected model. The examples use png.

Пример:

"png"

Ответ

200 - application/json

With async: false, successful generation returns status: "Ready" and the image URL in result.sample. With async: true or no async field, save the top-level id and poll the CometAPI result endpoint.

id
string
обязательно

Task ID to pass to GET /flux/v1/get_result?id=....

status
string
обязательно

Task state. A successful synchronous response returns Ready. An asynchronous submission can return Pending while generation continues.

result
object | null

Generation result. A successful synchronous response contains the finished image. An asynchronous submission can return an empty or null result.

polling_url
string | null

Response-supplied convenience URL when returned. Clients should poll the documented CometAPI result route by the top-level id.

cost
number | null

Numeric billing coefficient when returned. This field is not documented as a currency or credit amount.

input_mp
number | null

Input image megapixels when returned.

output_mp
number | null

Output image megapixels when returned.

progress
number | null

Task progress when returned.

details
any

Additional task details when returned.

preview
any

Task preview data when returned.

Последнее изменение 21 сентября 2026 г.