Skip to main content
POST

概述

POST /flux/v1/\{model\} 提交原生 BFL 格式的图像任务。保存顶层响应中的 id,然后轮询 GET /flux/v1/get_result ,并使用该任务 ID。 API Playground 提供了 FLUX.2 Pro、Flex 和 Max 的文本生成图像请求示例。请查看 模型页面/v1/models,以了解模型 ID 和账户可用性。

请求字段

首先使用 promptwidthheightoutput_format。您还可以发送 seed;完成后的结果可以报告所用的 seed,但仅凭该字段无法保证输出可复现。 对于参考图编辑,请在 input_image 中发送公共 HTTPS 图像 URL。上述三种 FLUX.2 模型均支持该字段。FLUX.2 Pro 还接受 input_image_2 中的第二个公共 HTTPS URL;每当发送 input_image 时,请包含 input_image_2

提交并轮询

创建响应在任务运行期间可能使用 status: "processing"。将其顶层 id 与 CometAPI 结果端点配合使用;客户端不应依赖响应提供的 polling_url 轮询,直到结果端点返回 status: "Ready"。将 ErrorFailedFailureTask not foundRequest ModeratedContent Moderated 视为失败。对于其他状态,请在应用程序的重试和超时限制内继续轮询。
任务就绪时,result.sample 是临时图像 URL。请及时下载或转存;不要依赖固定的有效期。

授权

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

路径参数

model
string
必填

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

请求体

application/json
prompt
string
必填

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

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.

示例:

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

示例:

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

示例:

1280

height
integer

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

示例:

768

output_format
string

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

示例:

"png"

响应

200 - application/json

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

id
string
必填

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

status
string
必填

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.

最后修改于 2026年7月31日