FLUX görüntüsü oluşturun
CometAPI’nin BFL ile uyumlu yerel endpoint’i aracılığıyla FLUX.2 metinden görüntüye ve referans görüntü görevleri gönderin.
Genel bakış
POST /flux/v1/\{model\} yerel BFL biçimli bir istekle görüntü oluşturur. İstekler varsayılan olarak asenkrondur. Üst düzey yanıttaki id değerini saklayın, ardından yoklamak için GET /flux/v1/get_result bu görev kimliğini kullanın.
Görüntüyü aynı istekte beklemek için JSON gövdesinde "async": false gönderin. Başarılı bir eşzamanlı yanıt, status: "Ready" ile birlikte result.sample içinde görüntü URL’sini içerir.
API playground, FLUX.2 Pro, Flex ve Max için metinden görüntüye istek örnekleri içerir. Şunu inceleyin: Modeller sayfası veya model kimlikleri ve hesap kullanılabilirliği için /v1/models.
İstek alanları
prompt, width, height ve output_format ile başlayın. seed de gönderebilirsiniz; tamamlanan sonuç kullanılan seed değerini bildirebilir, ancak bu alan tek başına tekrarlanabilir çıktı sağlamaz.
İsteğe bağlı async alanı, isteğin nasıl döneceğini kontrol eder. Eşzamanlı oluşturma için JSON boolean değeri false kullanın. Asenkron oluşturma için true kullanın veya alanı atlayın. "false" gibi bir string göndermeyin.
Referans görüntü düzenleme için input_image içinde herkese açık bir HTTPS görüntü URL’si gönderin. Bu alan yukarıdaki üç FLUX.2 modeli için desteklenir. FLUX.2 Pro ayrıca input_image_2 içinde ikinci bir herkese açık HTTPS URL’sini kabul eder; input_image gönderdiğinizde her zaman input_image_2 ekleyin.
Eşzamanlı olarak oluşturun
Seçin Eşzamanlı metinden görüntüye (FLUX.2 Pro) istek örneklerinde"async": false göndermek için. Görüntü oluşturulurken bağlantıyı açık tutun. Örnek 300 saniyelik bir istemci timeout değeri kullanır; bu, tamamlanma son tarihi değil, bir istemci ayarıdır.
Yanıt status: "Ready" içerdiğinde, result.sample değerini doğrudan okuyun. Sonuç yoklaması gerekmez. İstek başarısız olursa, sonucu okumadan önce HTTP hatasını işleyin.
async: false ile webhook_url veya webhook_secret değerlerini birleştirmeyin. Eşzamanlı istekler sonucu doğrudan döndürür ve bu webhook alanlarını reddeder.
Asenkron olarak gönderin ve yoklayın
async, true olduğunda veya atlandığında, oluşturma yanıtı oluşturma devam ederken bir görev kimliği döndürür. CometAPI sonuç endpoint’i ile üst düzey id değerini kullanın; istemciler yanıtta sağlanan polling_url değerine bağımlı olmamalıdır.
Sonuç endpoint’i status: "Ready" döndürene kadar yoklayın. Error, Failed, Failure, Task not found, Request Moderated ve Content Moderated değerlerini başarısızlık olarak değerlendirin. Diğer durumlar için uygulamanızın yeniden deneme ve timeout sınırları dahilinde yoklamaya devam edin.
Yetkilendirmeler
Bearer token authentication. Use your CometAPI key.
Yol Parametreleri
FLUX.2 model ID in the URL path. Check /v1/models or the Models page for account availability.
Gövde
Text prompt describing the image or reference-image edit.
"A clean editorial photograph of a red ceramic teapot on a pale blue table, soft window light, no text."
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.
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.
"https://your-image-host/reference-one.jpg"
Public HTTPS URL of a second reference image for flux-2-pro. Replace the example URL and also send input_image.
"https://your-image-host/reference-two.jpg"
Optional seed value. A completed result can report the used seed; that field alone does not establish repeatable output.
Requested output width in pixels. Use a dimension supported by the selected model.
1280
Requested output height in pixels. Use a dimension supported by the selected model.
768
Requested output image format supported by the selected model. The examples use png.
"png"
Yanıt
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.
Task ID to pass to GET /flux/v1/get_result?id=....
Task state. A successful synchronous response returns Ready. An asynchronous submission can return Pending while generation continues.
Generation result. A successful synchronous response contains the finished image. An asynchronous submission can return an empty or null result.
Response-supplied convenience URL when returned. Clients should poll the documented CometAPI result route by the top-level id.
Numeric billing coefficient when returned. This field is not documented as a currency or credit amount.
Input image megapixels when returned.
Output image megapixels when returned.
Task progress when returned.
Additional task details when returned.
Task preview data when returned.