Flux
Buat gambar FLUX
Kirim tugas text-to-image dan reference-image FLUX.2 melalui endpoint native CometAPI yang kompatibel dengan BFL.
POST
/
flux
/
v1
/
{model}
curl https://api.cometapi.com/flux/v1/flux-2-pro \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.",
"seed": 424242,
"width": 1280,
"height": 768,
"output_format": "png"
}'{
"id": "<task_id>",
"status": "Pending",
"result": {},
"polling_url": "https://api.cometapi.com/flux/v1/get_result?id=<task_id>"
}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 denganprompt, 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
Saatasync 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.Parameter Path
Body
application/json
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.
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.
Terakhir diubah pada 21 September 2026
⌘I
curl https://api.cometapi.com/flux/v1/flux-2-pro \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A clean editorial photograph of a red ceramic teapot on a pale blue table, a small yellow lemon on the right, soft window light, no text.",
"seed": 424242,
"width": 1280,
"height": 768,
"output_format": "png"
}'{
"id": "<task_id>",
"status": "Pending",
"result": {},
"polling_url": "https://api.cometapi.com/flux/v1/get_result?id=<task_id>"
}