- Third-party
FLUX.2 [max] 是 Black Forest Labs 画质最高的图像模型——拥有顶级的编辑一致性和最强的提示词遵循能力,并支持基于实时信息搜索的可视化生成。
| 模型信息 | |
|---|---|
| 条款和许可证 | 链接 ↗ |
| 更多信息 | 链接 ↗ |
| 定价 | 在 Cloudflare 仪表板中查看定价 ↗ |
用法
const response = await env.AI.run(
'black-forest-labs/flux-2-max',
{
prompt:
'A cat on its back legs running like a human is holding a big silver fish with its arms. The cat is running away from the shop owner and has a panicked look on his face. The scene is situated in a crowded market.',
height: 2048,
width: 1440,
},
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "black-forest-labs/flux-2-max",
"input": {
"prompt": "A cat on its back legs running like a human is holding a big silver fish with its arms. The cat is running away from the shop owner and has a panicked look on his face. The scene is situated in a crowded market.",
"height": 2048,
"width": 1440
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-max/high-resolution-scene.jpeg"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}示例
十六进制颜色控制 — 通过十六进制颜色代码精确控制颜色——适用于保持品牌一致性的图像
const response = await env.AI.run(
'black-forest-labs/flux-2-max',
{
prompt:
'A vase on a table in living room, the color of the vase is a gradient of color, starting with color #02eb3c and finishing with color #edfa3c. The flowers inside the vase have the color #ff0088',
},
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "black-forest-labs/flux-2-max",
"input": {
"prompt": "A vase on a table in living room, the color of the vase is a gradient of color, starting with color #02eb3c and finishing with color #edfa3c. The flowers inside the vase have the color #ff0088"
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-max/hex-color-control.jpeg"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}图像编辑 — 单参考图像编辑——为产品照片重新打光或重新布景
const response = await env.AI.run(
'black-forest-labs/flux-2-max',
{
prompt: 'Place this product onto a minimalist marble countertop with soft window light',
input_images: [
'https://replicate.delivery/xezq/jCypj4MeXYUiRyq7nfgm8z1OvFZF81wh4FznutDsZOuJz0YWA/tmp1iukn307.jpg',
],
},
)
console.log(response)curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "black-forest-labs/flux-2-max",
"input": {
"prompt": "Place this product onto a minimalist marble countertop with soft window light",
"input_images": [
"https://replicate.delivery/xezq/jCypj4MeXYUiRyq7nfgm8z1OvFZF81wh4FznutDsZOuJz0YWA/tmp1iukn307.jpg"
]
}
}'
{
"state": "Completed",
"result": {
"image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-max/image-editing.jpeg"
},
"gatewayMetadata": {
"keySource": "Unified"
}
}参数
prompt
stringrequired用于图像生成或编辑的文本提示词。seed
integerminimum: -9007199254740991maximum: 9007199254740991可选的种子,用于可复现的生成结果。width
integerminimum: 64maximum: 9007199254740991生成图像的宽度(像素,最小 64)。省略时由 BFL 选择。height
integerminimum: 64maximum: 9007199254740991生成图像的高度(像素,最小 64)。省略时由 BFL 选择。safety_tolerance
integerminimum: 0maximum: 5输入/输出审核的容忍度。0 最严格,5 最宽松。默认为 2。output_format
stringenum: jpeg, png, webp输出图像格式。默认为 jpeg。▶input_images[]
arraymaxItems: 8最多 8 张参考图像,用于编辑或多图合成。每个条目可以是 HTTPS URL 或 data:image/...;base64,... URI。image
stringformat: uri生成图像的 URL