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

FLUX.2 [flex]

Text-to-Image • Black Forest Labs

查看 MarkdownAgent 设置
  • Third-party

FLUX.2 [flex] 是 Black Forest Labs 推出的 FLUX.2 精细控制版本——提供可调的推理步数、引导强度和提示词扩写,适用于文字排版密集型和生产工作流。

模型信息
条款和许可证链接 ↗
更多信息链接 ↗
定价在 Cloudflare 仪表板中查看定价 ↗

用法

const response = await env.AI.run(
  'black-forest-labs/flux-2-flex',
  {
    prompt:
      "Samsung Galaxy S25 Ultra product advertisement, 'Ultra-strong titanium' headline, close-up of phone edge showing titanium frame, dark gradient background, clean minimalist tech aesthetic",
  },
)
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-flex",
  "input": {
    "prompt": "Samsung Galaxy S25 Ultra product advertisement, '\''Ultra-strong titanium'\'' headline, close-up of phone edge showing titanium frame, dark gradient background, clean minimalist tech aesthetic"
  }
}'
文字排版与设计
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-flex/typography-design.jpeg"
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

示例

高细节生成 — 在不优先考虑延迟时,调高步数和引导强度以获得最大细节
const response = await env.AI.run(
  'black-forest-labs/flux-2-flex',
  {
    prompt: 'A detailed oil painting portrait of a Renaissance nobleman with intricate lace collar',
    guidance: 7.5,
    steps: 50,
  },
)
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-flex",
  "input": {
    "prompt": "A detailed oil painting portrait of a Renaissance nobleman with intricate lace collar",
    "guidance": 7.5,
    "steps": 50
  }
}'
高细节生成
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-flex/high-detail-generation.jpeg"
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}
快速草稿 — 禁用提示词扩写的快速草稿——保留原始提示词
const response = await env.AI.run(
  'black-forest-labs/flux-2-flex',
  { prompt: 'A simple line sketch of a mountain landscape', prompt_upsampling: false, steps: 10 },
)
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-flex",
  "input": {
    "prompt": "A simple line sketch of a mountain landscape",
    "prompt_upsampling": false,
    "steps": 10
  }
}'
快速草稿
{
  "state": "Completed",
  "result": {
    "image": "https://examples.aig.cloudflare.com/black-forest-labs/flux-2-flex/fast-draft.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。
prompt_upsampling
booleanBFL 是否在生成前扩写简短提示词。在 flex 上默认为 true。
guidance
numberminimum: 1.5maximum: 10无分类器引导(classifier-free guidance)比例(1.5–10)。值越高,越严格地遵循提示词,但会牺牲真实感。
steps
integerminimum: 1maximum: 50去噪步数(1–50)。步数越多,细节越丰富,但延迟越高。
image
stringformat: uri生成图像的 URL

API schema(原始)

输入
输出

这篇文档对您有帮助吗?