Saltar para o conteúdo principal
POST

Visão geral

POST /flux/v1/\{model\} gera uma imagem com uma solicitação nativa no formato BFL. As solicitações são assíncronas por padrão. Armazene o id de nível superior da resposta e, em seguida, consulte GET /flux/v1/get_result usando esse ID de tarefa. Para aguardar a imagem na mesma solicitação, envie "async": false no corpo JSON. Uma resposta síncrona bem-sucedida contém status: "Ready" e a URL da imagem em result.sample. O playground da API inclui exemplos de solicitações de texto para imagem para FLUX.2 Pro, Flex e Max. Consulte a página Models ou /v1/models para IDs de modelo e disponibilidade da conta.

Campos da solicitação

Comece com prompt, width, height e output_format. Você também pode enviar seed; o resultado concluído pode informar a seed usada, mas esse campo isoladamente não garante uma saída reproduzível. O campo opcional async controla como a solicitação retorna. Use o booleano JSON false para geração síncrona. Use true ou omita o campo para geração assíncrona. Não envie uma string como "false". Para edição de imagem de referência, envie uma URL pública de imagem HTTPS em input_image. Esse campo é compatível com os três modelos FLUX.2 acima. FLUX.2 Pro também aceita uma segunda URL pública HTTPS em input_image_2; inclua input_image sempre que enviar input_image_2.

Gerar de forma síncrona

Selecione Texto para imagem síncrono (FLUX.2 Pro) nos exemplos de solicitação para enviar "async": false. Mantenha a conexão aberta enquanto a imagem é gerada. O exemplo usa um tempo limite de cliente de 300 segundos; essa é uma configuração do cliente, não um prazo de conclusão. Quando a resposta tiver status: "Ready", leia result.sample diretamente. Não é necessário consultar o resultado. Se a solicitação falhar, trate o erro HTTP antes de ler o resultado. Não combine async: false com webhook_url ou webhook_secret. As solicitações síncronas retornam o resultado diretamente e rejeitam esses campos de webhook.

Enviar de forma assíncrona e consultar

Quando async for true ou for omitido, a resposta de criação retornará um ID de tarefa enquanto a geração continua. Use seu id de nível superior com o endpoint de resultado da CometAPI; os clientes não devem depender de um polling_url fornecido na resposta. Consulte até que o endpoint de resultado retorne status: "Ready". Considere Error, Failed, Failure, Task not found, Request Moderated e Content Moderated como falhas. Para outros estados, continue consultando dentro dos limites de repetição e tempo limite da sua aplicação.
Quando uma tarefa estiver pronta, result.sample será uma URL temporária de imagem. Baixe-a ou transfira-a imediatamente; não dependa de uma duração fixa.

Autorizações

Authorization
string
header
obrigatório

Bearer token authentication. Use your CometAPI key.

Parâmetros de caminho

model
string
obrigatório

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

Corpo

application/json
prompt
string
obrigatório

Text prompt describing the image or reference-image edit.

Exemplo:

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

async
boolean
padrão: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
obrigatório 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.

Exemplo:

"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.

Exemplo:

"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.

Exemplo:

1280

height
integer

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

Exemplo:

768

output_format
string

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

Exemplo:

"png"

Resposta

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
obrigatório

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

status
string
obrigatório

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.

Última modificação em 21 de setembro de 2026