> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyfast.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# FLUX.2 [flex]

> 通过 Anyfast API 调用 Black Forest Labs FLUX.2 [flex] 文生图模型。

FLUX.2 \[flex] 是 Black Forest Labs 推出的高度可配置文生图模型，通过 Anyfast 提供。提供精细的采样步数和引导系数控制，适合设计专家使用。API 为**同步调用** — 直接返回 Base64 编码的图片数据。

## 核心能力

* **文生图** — 根据文字描述生成图片
* **步数控制** — 调节采样步数（1–50），灵活平衡速度与画质
* **引导系数** — 精调提示词遵循程度（1.5–10）
* **高分辨率** — 支持最高 4MP 输出分辨率
* **可复现** — 使用 `seed` 实现确定性生成

## 快速示例

<CodeGroup>
  ```bash cURL theme={null}
  curl https://www.anyfast.ai/v1/images/generations \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "flux-2-flex",
      "prompt": "一只可爱的北极熊宝宝",
      "size": "1024x1024",
      "inference_steps": 30,
      "guidance_scale": 7.5
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://www.anyfast.ai/v1/images/generations",
      headers={"Authorization": "Bearer YOUR_API_KEY"},
      json={
          "model": "flux-2-flex",
          "prompt": "一只可爱的北极熊宝宝",
          "size": "1024x1024",
          "inference_steps": 30,
          "guidance_scale": 7.5
      }
  )

  result = response.json()
  # result["data"][0]["b64_json"] 包含 Base64 编码的图片
  ```
</CodeGroup>

## 参数说明

| 参数                | 类型      | 必填 | 说明                                      |
| ----------------- | ------- | -- | --------------------------------------- |
| `model`           | string  | 是  | 固定为 `flux-2-flex`                       |
| `prompt`          | string  | 是  | 图片描述文字                                  |
| `n`               | integer | 否  | 生成张数（1–4），默认 `1`                        |
| `size`            | string  | 否  | 输出尺寸，如 `1024x1024`，支持最高 4MP             |
| `inference_steps` | integer | 否  | 采样步数（1–50）。低步数（6–20）快速原型，高步数（40–50）极致保真 |
| `guidance_scale`  | number  | 否  | 引导系数（1.5–10）。数值越高越忠实于提示词                |
| `output_format`   | string  | 否  | `jpeg` 或 `png`                          |
| `seed`            | integer | 否  | 随机种子，用于复现                               |

## 响应字段

| 字段                | 说明             |
| ----------------- | -------------- |
| `data[].b64_json` | Base64 编码的图片数据 |
| `created`         | 创建时间戳          |

<Card title="API 参考" icon="code" href="/zh/api-reference/model-api/blackforestlabs/flux-2-flex">
  查看 FLUX.2 \[flex] 的交互式 API Playground。
</Card>

<script src="/feedback.js" />
