Skip to main content
POST

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ới prompt, width, heightoutput_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ùng status: "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 ModeratedContent 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.
Khi tác vụ sẵn sàng, result.sample là URL hình ảnh tạm thời. Hãy tải xuống hoặc chuyển nó ngay; không dựa vào thời hạn cố định.

Ủy quyền

Authorization
string
header
bắt buộc

Bearer token authentication. Use your CometAPI key.

Tham số đường dẫn

model
string
bắt buộc

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

Nội dung

application/json
prompt
string
bắt buộc

Text prompt describing the image or reference-image edit.

Ví dụ:

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

input_image
string

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.

Ví dụ:

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

Ví dụ:

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

Ví dụ:

1280

height
integer

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

Ví dụ:

768

output_format
string

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

Ví dụ:

"png"

Phản hồi

200 - application/json

FLUX task submission response. Save the top-level id and poll the CometAPI result endpoint.

id
string
bắt buộc

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

status
string
bắt buộc

Submission state. An accepted task can return processing.

result
object | null

Task result. It can be empty or null at submission time.

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.

Lần sửa đổi cuối 31 tháng 7, 2026