Przejdź do głównej treści
POST

Przegląd

POST /flux/v1/\{model\} generuje obraz przy użyciu żądania w natywnym formacie BFL. Żądania są domyślnie asynchroniczne. Zapisz id z odpowiedzi najwyższego poziomu, a następnie odpytuj GET /flux/v1/get_result za pomocą tego identyfikatora zadania. Aby oczekiwać na obraz w tym samym żądaniu, wyślij "async": false w treści JSON. Pomyślna odpowiedź synchroniczna zawiera status: "Ready" oraz adres URL obrazu w result.sample. Środowisko testowe API zawiera przykłady żądań generowania obrazów z tekstu dla FLUX.2 Pro, Flex i Max. Sprawdź stronę modeli lub /v1/models, aby uzyskać identyfikatory modeli i informacje o dostępności konta.

Pola żądania

Zacznij od prompt, width, height i output_format. Możesz również wysłać seed; ukończony wynik może zawierać użyty seed, ale samo to pole nie zapewnia powtarzalnych wyników. Opcjonalne pole async określa sposób zwracania wyniku przez żądanie. Do generowania synchronicznego użyj wartości logicznej JSON false. Do generowania asynchronicznego użyj true lub pomiń to pole. Nie wysyłaj ciągu znaków, takiego jak "false". Do edycji z obrazem referencyjnym wyślij publicznie dostępny adres URL obrazu HTTPS w input_image. To pole jest obsługiwane przez trzy wymienione powyżej modele FLUX.2. FLUX.2 Pro akceptuje również drugi publicznie dostępny adres URL HTTPS w input_image_2; dołączaj input_image zawsze, gdy wysyłasz input_image_2.

Generowanie synchroniczne

Wybierz Synchroniczna konwersja tekstu na obraz (FLUX.2 Pro) w przykładach żądań, aby wysłać "async": false. Utrzymuj otwarte połączenie podczas generowania obrazu. Przykład używa limitu czasu klienta wynoszącego 300 sekund; jest to ustawienie klienta, a nie termin ukończenia. Gdy odpowiedź zawiera status: "Ready", odczytaj bezpośrednio result.sample. Nie jest wymagane odpytywanie o wynik. Jeśli żądanie się nie powiedzie, obsłuż błąd HTTP przed odczytaniem wyniku. Nie łącz async: false z webhook_url ani webhook_secret. Żądania synchroniczne zwracają wynik bezpośrednio i odrzucają te pola webhooków.

Przesyłanie asynchroniczne i odpytywanie

Gdy async ma wartość true lub jest pominięte, odpowiedź na utworzenie zwraca identyfikator zadania, podczas gdy generowanie trwa nadal. Użyj wartości id z najwyższego poziomu wraz z endpointem wyników CometAPI; klienci nie powinni polegać na wartości polling_url przekazanej w odpowiedzi. Odpytywanie kontynuuj, aż endpoint wyników zwróci status: "Ready". Traktuj Error, Failed, Failure, Task not found, Request Moderated i Content Moderated jako błędy. W przypadku innych stanów kontynuuj odpytywanie w granicach limitów ponawiania i limitów czasu aplikacji.
Gdy zadanie jest gotowe, result.sample jest tymczasowym adresem URL obrazu. Pobierz go lub przenieś niezwłocznie; nie zakładaj stałego okresu ważności.

Autoryzacje

Authorization
string
header
wymagane

Bearer token authentication. Use your CometAPI key.

Parametry ścieżki

model
string
wymagane

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

Treść

application/json
prompt
string
wymagane

Text prompt describing the image or reference-image edit.

Przykład:

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

async
boolean
domyślnie: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
wymagane 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.

Przykład:

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

Przykład:

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

Przykład:

1280

height
integer

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

Przykład:

768

output_format
string

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

Przykład:

"png"

Odpowiedź

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
wymagane

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

status
string
wymagane

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.

Ostatnia modyfikacja 21 września 2026