flux
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFlux CLI (BFL / FLUX)
Flux CLI(BFL / FLUX)
CLI to generate and edit images via the BFL FLUX API.
一款可通过BFL FLUX API生成和编辑图片的CLI工具。
Quick start
快速开始
- API key:
- env:
export BFL_API_KEY="..."
- or save locally (reads from stdin; avoid shell history leaks):
echo "$BFL_API_KEY" | flux config set apiKey
- Generate:
flux gen "a cat astronaut" --model flux-2-pro --width 1024 --height 1024 -o out/
- Edit with a reference image:
flux edit "make it sunset lighting" --model flux-2-pro --input ./in.jpg -o out/
- API密钥:
- 环境变量方式:
export BFL_API_KEY="..."
- 或本地保存(从标准输入读取;避免泄露到shell历史):
echo "$BFL_API_KEY" | flux config set apiKey
- 生成图片:
flux gen "a cat astronaut" --model flux-2-pro --width 1024 --height 1024 -o out/
- 基于参考图编辑:
flux edit "make it sunset lighting" --model flux-2-pro --input ./in.jpg -o out/
Commands
命令说明
flux gen [prompt]- text-to-image
- prompt can be positional, or / stdin
-
flux edit [prompt] --input <path|url|base64> [--input ...]- image editing using a prompt + 1..N input images (base + refs)
flux fill [prompt] --image <path|url|base64> [--mask <path|url|base64>]- inpaint (explicit mask image, or alpha channel)
flux expand [prompt] --image <path|url|base64> [--top/--bottom/--left/--right <px>]- outpaint (expand canvas by pixels on any side)
flux result <id> [--out <path|->]- fetch status/result by id
- if and
status=Readyis set, downloads the result--out
flux wait <id> [--polling-url <url>] [--out <path|->]- wait until /error; optionally download the result
Ready
flux credits- show remaining credits
flux models- list model keys supported by the CLI
flux config path|get|set|unset- local config (including saving API key via stdin)
flux gen [prompt]- 文本生成图片
- prompt可以是位置参数,或使用从标准输入读取
-
flux edit [prompt] --input <path|url|base64> [--input ...]- 结合prompt和1至N张输入图(基础图+参考图)进行图片编辑
flux fill [prompt] --image <path|url|base64> [--mask <path|url|base64>]- 图像修复(支持显式蒙版图或alpha通道)
flux expand [prompt] --image <path|url|base64> [--top/--bottom/--left/--right <px>]- 图像扩展(在任意方向按像素扩展画布)
flux result <id> [--out <path|->]- 通过ID获取任务状态/结果
- 若状态为且设置了
Ready,则自动下载结果--out
flux wait <id> [--polling-url <url>] [--out <path|->]- 等待任务完成(就绪/错误);可选择自动下载结果
flux credits- 查看剩余余额
flux models- 列出CLI支持的模型密钥
flux config path|get|set|unset- 本地配置管理(包括通过标准输入保存API密钥)
Global flags
全局参数
- : single JSON object to stdout (for scripts)
--json - : stable line output (paths/ids)
--plain - : less logging
-q, --quiet - : diagnostics to stderr (no secrets)
-v, --verbose - : API host (default
--endpoint <host>)api.bfl.ai - : endpoint shortcut
--region <us|eu|global> - : timeout
--timeout <ms> - : retries for 429/5xx
--retries <n> - : default output directory
--out-dir <dir>
- : 向标准输出输出单个JSON对象(适用于脚本)
--json - : 输出稳定的行格式(路径/ID)
--plain - : 减少日志输出
-q, --quiet - : 向标准错误输出诊断信息(不包含敏感信息)
-v, --verbose - : API主机地址(默认
--endpoint <host>)api.bfl.ai - : API区域快捷选择
--region <us|eu|global> - : 请求超时时间
--timeout <ms> - : 针对429/5xx错误的重试次数
--retries <n> - : 默认输出目录
--out-dir <dir>
Common gen/edit flags
生成/编辑通用参数
- : model key (see
--model <key>)flux models --seed <n>- : safety_tolerance (range depends on model)
--safety <n> - : output_format
--format <jpeg|png> - : file/dir or
-o, --out <path|->for stdout- - : submit only; print
--no-wait(+idinpollingUrl)--json --poll-interval <ms>
Advanced (escape hatch):
- : raw request body (full control)
--body <json|@file>
- : 模型密钥(可通过
--model <key>查看)flux models - : 随机种子
--seed <n> - : 安全容忍度(范围取决于模型)
--safety <n> - : 输出格式
--format <jpeg|png> - : 文件/目录,或使用
-o, --out <path|->输出到标准输出- - : 仅提交任务;输出
--no-wait(使用id时会额外输出--json)pollingUrl - : 轮询间隔时间
--poll-interval <ms>
高级用法(自定义请求):
- : 原始请求体(完全自定义控制)
--body <json|@file>
Models (keys)
模型(密钥)
Official model lineup evolves; use for the current list.
flux modelsBuilt-in keys, when to use them, and pricing tier (rule of thumb; pricing can change):
| Model key | Best for | Pricing tier | Notes |
|---|---|---|---|
| quick drafts; high-volume generation | cheap | MP-based |
| better drafts; still fast iteration | cheap-to-balanced | MP-based |
| default pick; production workflows; general-purpose gen/edit | balanced | MP-based; edits typically cost more than T2I |
| maximum quality with control knobs | premium | MP-based; supports |
| final assets; quality-first; grounding search | premium/most expensive | MP-based |
| controlled edits/variations with multiple references | balanced | credits per call |
| stronger Kontext edits; quality-first | expensive | credits per call |
| FLUX 1.1 behavior; compatibility workflows | balanced | credits per call |
| Ultra mode; aspect-ratio driven generation; optional raw look | expensive | credits per call |
| inpainting (mask/alpha) | expensive | credits per call (tool endpoint) |
| outpainting (extend canvas) | mid-to-expensive | tool endpoint; check returned |
| passthrough via | cheap | credits per call; check returned |
| passthrough via | varies | check returned |
Footnote:
- MP-based: cost scales with output size in megapixels (width * height / 1,000,000). Larger images cost more.
官方模型阵容会不断更新;使用查看当前列表。
flux models以下是内置模型密钥、适用场景、价格档位(仅供参考;价格可能变动):
| 模型密钥 | 适用场景 | 价格档位 | 说明 |
|---|---|---|---|
| 快速草稿;大批量生成 | 低廉 | 基于MP计费 |
| 更高质量草稿;仍支持快速迭代 | 低廉至适中 | 基于MP计费 |
| 默认选择;生产工作流;通用生成/编辑 | 适中 | 基于MP计费;编辑通常比文本生成图片成本更高 |
| 极致画质,支持更多控制参数 | 高端 | 基于MP计费;支持 |
| 最终资产;画质优先;支持 grounding 搜索 | 高端/最贵 | 基于MP计费 |
| 多参考图控制下的编辑/变体生成 | 适中 | 按调用次数计费 |
| 更强的Kontext编辑能力;画质优先 | 昂贵 | 按调用次数计费 |
| 兼容FLUX 1.1行为;适配兼容工作流 | 适中 | 按调用次数计费 |
| 超高清模式;基于宽高比的生成;可选原生风格 | 昂贵 | 按调用次数计费 |
| 图像修复(蒙版/alpha通道) | 昂贵 | 按调用次数计费(工具端点) |
| 图像扩展(画布延伸) | 中高价位 | 工具端点;需查看返回的 |
| 当你熟悉API结构时,通过 | 低廉 | 按调用次数计费;需查看返回的 |
| 当你熟悉API结构时,通过 | 档位不一 | 需查看返回的 |
注:
- 基于MP计费:成本随输出图片的像素数(宽 × 高 / 1,000,000)递增,图片越大成本越高。
Safety / reliability notes
安全与可靠性说明
- API key: avoid passing secrets via flags; use env/config/stdin.
- Signed URL: is typically short-lived; download immediately.
result.sample
- API密钥:避免通过参数传递敏感信息;使用环境变量/配置文件/标准输入方式。
- 签名URL:通常有效期较短;请立即下载。
result.sample
Common errors (exit codes)
常见错误(退出码)
- : invalid args/validation
2 - : missing key or
3403 - :
4(insufficient credits)402 - :
5(rate limit)429 - : moderation
6 - : other API/task errors
7
- : 参数无效/验证失败
2 - : 密钥缺失或返回
3错误403 - :
4错误(余额不足)402 - :
5错误(请求频率超限)429 - : 内容审核不通过
6 - : 其他API/任务错误
7