Naar hoofdinhoud gaan
POST

Overzicht

POST /flux/v1/\{model\} genereert een afbeelding met een native aanvraag in BFL-indeling. Aanvragen zijn standaard asynchroon. Sla de id op het hoogste niveau van de respons op en poll vervolgens GET /flux/v1/get_result met die taak-ID. Als je binnen dezelfde aanvraag op de afbeelding wilt wachten, stuur je "async": false in de JSON-body. Een succesvolle synchrone respons bevat status: "Ready" en de afbeeldings-URL in result.sample. De API-playground bevat voorbeelden van tekst-naar-afbeeldingsaanvragen voor FLUX.2 Pro, Flex en Max. Bekijk de pagina Modellen of /v1/models voor model-ID’s en accountbeschikbaarheid.

Aanvraagvelden

Begin met prompt, width, height en output_format. Je kunt ook seed sturen; het voltooide resultaat kan de gebruikte seed rapporteren, maar dat veld alleen zorgt niet voor reproduceerbare uitvoer. Het optionele veld async bepaalt hoe de aanvraag wordt geretourneerd. Gebruik de JSON-booleaanse waarde false voor synchrone generatie. Gebruik true of laat het veld weg voor asynchrone generatie. Stuur geen tekenreeks zoals "false". Voor het bewerken van referentieafbeeldingen stuur je een openbare HTTPS-afbeeldings-URL in input_image. Dit veld wordt ondersteund voor de drie bovenstaande FLUX.2-modellen. FLUX.2 Pro accepteert ook een tweede openbare HTTPS-URL in input_image_2; voeg altijd input_image toe wanneer je input_image_2 verstuurt.

Synchroon genereren

Selecteer Synchrone tekst naar afbeelding (FLUX.2 Pro) in de aanvraagvoorbeelden om "async": false te sturen. Houd de verbinding open terwijl de afbeelding wordt gegenereerd. Het voorbeeld gebruikt een clienttime-out van 300 seconden; dit is een clientinstelling, geen deadline voor voltooiing. Wanneer de respons status: "Ready" bevat, lees je result.sample rechtstreeks. Het pollen van resultaten is niet nodig. Als de aanvraag mislukt, handel dan de HTTP-fout af voordat je het resultaat leest. Combineer async: false niet met webhook_url of webhook_secret. Synchrone aanvragen retourneren het resultaat rechtstreeks en weigeren deze webhookvelden.

Asynchroon indienen en pollen

Wanneer async true is of wordt weggelaten, retourneert de aanmaakrespons een taak-ID terwijl de generatie doorgaat. Gebruik de id op het hoogste niveau met het CometAPI-resultaatendpoint; clients mogen niet afhankelijk zijn van een door de respons opgegeven polling_url. Poll totdat het resultaatendpoint status: "Ready" retourneert. Behandel Error, Failed, Failure, Task not found, Request Moderated en Content Moderated als fouten. Blijf voor andere statussen pollen binnen de limieten voor opnieuw proberen en time-outs van je applicatie.
Wanneer een taak gereed is, is result.sample een tijdelijke afbeeldings-URL. Download of verplaats deze snel; vertrouw niet op een vaste geldigheidsduur.

Autorisaties

Authorization
string
header
vereist

Bearer token authentication. Use your CometAPI key.

Padparameters

model
string
vereist

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

Body

application/json
prompt
string
vereist

Text prompt describing the image or reference-image edit.

Voorbeeld:

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

async
boolean
standaard: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
vereist 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.

Voorbeeld:

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

Voorbeeld:

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

Voorbeeld:

1280

height
integer

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

Voorbeeld:

768

output_format
string

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

Voorbeeld:

"png"

Respons

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
vereist

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

status
string
vereist

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.

Laatst gewijzigd op 21 september 2026