Tạo hình ảnh FLUX
Gửi các tác vụ chuyển văn bản thành hình ảnh và hình ảnh tham chiếu FLUX.2 qua endpoint gốc tương thích BFL của CometAPI.
Tổng quan
POST /flux/v1/\{model\} gửi một tác vụ hình ảnh ở định dạng BFL gốc. Lưu giá trị id ở cấp cao nhất của phản hồi, sau đó thăm dò GET /flux/v1/get_result bằng ID tác vụ đó.
Trình thử nghiệm API có các ví dụ yêu cầu chuyển văn bản thành hình ảnh cho FLUX.2 Pro, Flex và Max. Hãy xem trang Models hoặc /v1/models để biết ID mô hình và tình trạng khả dụng của tài khoản.
Các trường yêu cầu
Bắt đầu vớiprompt, width, height và output_format. Bạn cũng có thể gửi seed; kết quả hoàn tất có thể báo cáo seed đã dùng, nhưng riêng trường đó không đảm bảo đầu ra có thể tái lập.
Để chỉnh sửa hình ảnh tham chiếu, hãy gửi URL hình ảnh HTTPS công khai trong input_image. Trường này được hỗ trợ cho ba mô hình FLUX.2 nêu trên. FLUX.2 Pro cũng chấp nhận URL HTTPS công khai thứ hai trong input_image_2; hãy thêm input_image bất cứ khi nào gửi input_image_2.
Gửi và thăm dò
Phản hồi tạo có thể dùngstatus: "processing" trong khi tác vụ đang chạy. Dùng id cấp cao nhất của phản hồi đó với endpoint kết quả của CometAPI; client không nên phụ thuộc vào polling_url được cung cấp trong phản hồi.
Thăm dò cho đến khi endpoint kết quả trả về status: "Ready". Coi Error, Failed, Failure, Task not found, Request Moderated và Content Moderated là lỗi. Với các trạng thái khác, hãy tiếp tục thăm dò trong giới hạn thử lại và thời gian chờ của ứng dụng.
Ủy quyền
Bearer token authentication. Use your CometAPI key.
Tham số đường dẫn
FLUX.2 model ID in the URL path. Check /v1/models or the Models page for account availability.
Nội dung
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."
Public HTTPS URL of the first reference image. Replace the example URL with an image that the model provider can retrieve. 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"
Phản hồi
FLUX task submission response. Save the top-level id and poll the CometAPI result endpoint.
Task ID to pass to GET /flux/v1/get_result?id=....
Submission state. An accepted task can return processing.
Task result. It can be empty or null at submission time.
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.