跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com
Black Forest Labs logo

FLUX.2 [max]

Text-to-Image • Black Forest Labs

查看 MarkdownAgent 设置
  • 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。
image
stringformat: uri生成图像的 URL

API schema(原始)

输入
输出

这篇文档对您有帮助吗?