生成 FLUX 图像
通过 CometAPI 的原生 BFL 兼容端点提交 FLUX.2 文本生成图像和参考图任务。
概述
POST /flux/v1/\{model\} 提交原生 BFL 格式的图像任务。保存顶层响应中的 id,然后轮询 GET /flux/v1/get_result ,并使用该任务 ID。
API Playground 提供了 FLUX.2 Pro、Flex 和 Max 的文本生成图像请求示例。请查看 模型页面 或 /v1/models,以了解模型 ID 和账户可用性。
请求字段
首先使用prompt、width、height 和 output_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"。将 Error、Failed、Failure、Task not found、Request Moderated 和 Content Moderated 视为失败。对于其他状态,请在应用程序的重试和超时限制内继续轮询。
授权
Bearer token authentication. Use your CometAPI key.
路径参数
FLUX.2 model ID in the URL path. Check /v1/models or the Models page for account availability.
请求体
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"
响应
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.