Langsung ke konten utama
POST

Ringkasan

POST /flux/v1/\{model\} menghasilkan gambar dengan request berformat BFL native. Request bersifat asynchronous secara default. Simpan id respons tingkat atas, lalu poll GET /flux/v1/get_result dengan ID tugas tersebut. Untuk menunggu gambar dalam request yang sama, kirim "async": false dalam body JSON. Respons synchronous yang berhasil berisi status: "Ready" dan URL gambar dalam result.sample. API playground menyertakan contoh request text-to-image untuk FLUX.2 Pro, Flex, dan Max. Lihat halaman Models atau /v1/models untuk ID model dan ketersediaan akun.

Field request

Mulai dengan prompt, width, height, dan output_format. Anda juga dapat mengirim seed; hasil yang selesai dapat melaporkan seed yang digunakan, tetapi field tersebut saja tidak menjamin output yang dapat diulang. Field opsional async mengontrol cara request mengembalikan hasil. Gunakan boolean JSON false untuk generation synchronous. Gunakan true atau hilangkan field tersebut untuk generation asynchronous. Jangan kirim string seperti "false". Untuk pengeditan reference-image, kirim URL gambar HTTPS publik dalam input_image. Field ini didukung untuk tiga model FLUX.2 di atas. FLUX.2 Pro juga menerima URL HTTPS publik kedua dalam input_image_2; sertakan input_image setiap kali Anda mengirim input_image_2.

Buat secara synchronous

Pilih Text to image synchronous (FLUX.2 Pro) dalam contoh request untuk mengirim "async": false. Biarkan koneksi tetap terbuka selama gambar dibuat. Contoh tersebut menggunakan timeout klien 300 detik; ini adalah pengaturan klien, bukan batas waktu penyelesaian. Saat respons memiliki status: "Ready", baca result.sample secara langsung. Tidak perlu melakukan polling hasil. Jika request gagal, tangani error HTTP sebelum membaca hasil. Jangan gabungkan async: false dengan webhook_url atau webhook_secret. Request synchronous mengembalikan hasil secara langsung dan menolak field webhook ini.

Kirim secara asynchronous dan lakukan polling

Saat async bernilai true atau dihilangkan, respons create mengembalikan ID tugas sementara generation berlanjut. Gunakan id tingkat atasnya dengan endpoint hasil CometAPI; klien tidak boleh bergantung pada polling_url yang disediakan respons. Lakukan polling hingga endpoint hasil mengembalikan status: "Ready". Perlakukan Error, Failed, Failure, Task not found, Request Moderated, dan Content Moderated sebagai kegagalan. Untuk status lain, lanjutkan polling dalam batas retry dan timeout aplikasi Anda.
Saat tugas siap, result.sample adalah URL gambar sementara. Unduh atau transfer segera; jangan mengandalkan masa berlaku tetap.

Otorisasi

Authorization
string
header
wajib

Bearer token authentication. Use your CometAPI key.

Parameter Path

model
string
wajib

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

Body

application/json
prompt
string
wajib

Text prompt describing the image or reference-image edit.

Contoh:

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

async
boolean
default: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
wajib 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.

Contoh:

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

Contoh:

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

Contoh:

1280

height
integer

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

Contoh:

768

output_format
string

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

Contoh:

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

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

status
string
wajib

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.

Terakhir diubah pada 21 September 2026