Vai al contenuto principale
POST

Panoramica

POST /flux/v1/\{model\} genera un’immagine con una richiesta nativa in formato BFL. Per impostazione predefinita, le richieste sono asincrone. Memorizza il valore di primo livello della risposta id, quindi esegui il polling di GET /flux/v1/get_result con quell’ID attività. Per attendere l’immagine nella stessa richiesta, invia "async": false nel corpo JSON. Una risposta sincrona riuscita contiene status: "Ready" e l’URL dell’immagine in result.sample. Il playground API include esempi di richieste da testo a immagine per FLUX.2 Pro, Flex e Max. Consulta la pagina Models o /v1/models per gli ID modello e la disponibilità dell’account.

Campi della richiesta

Inizia con prompt, width, height e output_format. Puoi anche inviare seed; il risultato completato può riportare il seed utilizzato, ma quel campo da solo non garantisce un output ripetibile. Il campo facoltativo async controlla la modalità di restituzione della richiesta. Usa il booleano JSON false per la generazione sincrona. Usa true oppure ometti il campo per la generazione asincrona. Non inviare una stringa come "false". Per la modifica con immagini di riferimento, invia un URL HTTPS pubblico dell’immagine in input_image. Questo campo è supportato per i tre modelli FLUX.2 sopra indicati. FLUX.2 Pro accetta anche un secondo URL HTTPS pubblico in input_image_2; includi input_image ogni volta che invii input_image_2.

Generare in modo sincrono

Seleziona Generazione sincrona da testo a immagine (FLUX.2 Pro) negli esempi di richieste per inviare "async": false. Mantieni aperta la connessione durante la generazione dell’immagine. L’esempio usa un timeout del client di 300 secondi; si tratta di un’impostazione del client, non di una scadenza per il completamento. Quando la risposta contiene status: "Ready", leggi direttamente result.sample. Non è necessario eseguire il polling del risultato. Se la richiesta non riesce, gestisci l’errore HTTP prima di leggere il risultato. Non combinare async: false con webhook_url o webhook_secret. Le richieste sincrone restituiscono direttamente il risultato e rifiutano questi campi webhook.

Inviare in modo asincrono ed eseguire il polling

Quando async è true o viene omesso, la risposta di creazione restituisce un ID attività mentre la generazione continua. Usa il relativo id di primo livello con l’endpoint dei risultati CometAPI; i client non devono dipendere da un polling_url fornito nella risposta. Esegui il polling finché l’endpoint dei risultati non restituisce status: "Ready". Considera Error, Failed, Failure, Task not found, Request Moderated e Content Moderated come errori. Per gli altri stati, continua il polling entro i limiti di tentativi e timeout dell’applicazione.
Quando un’attività è pronta, result.sample è un URL temporaneo dell’immagine. Scaricala o trasferiscila tempestivamente; non fare affidamento su una durata fissa.

Autorizzazioni

Authorization
string
header
obbligatorio

Bearer token authentication. Use your CometAPI key.

Parametri del percorso

model
string
obbligatorio

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

Corpo

application/json
prompt
string
obbligatorio

Text prompt describing the image or reference-image edit.

Esempio:

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

async
boolean
predefinito: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
obbligatorio 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.

Esempio:

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

Esempio:

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

Esempio:

1280

height
integer

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

Esempio:

768

output_format
string

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

Esempio:

"png"

Risposta

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
obbligatorio

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

status
string
obbligatorio

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.

Ultima modifica il 21 settembre 2026