# FLUX.1 [dev] with Controlnets and Loras · Rf Inversion API

> 通过 RF inversion 根据提示词编辑参考图像

使用 RF-Inversion 流程，根据 `prompt` 编辑 `image_url` 中的图像。该流程从原图开始，而不是从噪声开始。可添加 LoRA、控制 LoRA、ControlNet 和参考图像，NAG 设置（`nag_scale`、`nag_tau`、`nag_alpha`、`nag_end`）用于调节负面提示词引导。

- Model id: `flux-general/rf-inversion`
- Made by: Black Forest Labs
- Category: Image Editing
- Output: image
- Estimated price per run: $0.025 / image (cheapest run $0.025 (25 API credits))
- Run: `POST https://api.doitong.com/v1/run/flux-general/rf-inversion`
- Quote: `POST https://api.doitong.com/v1/quote/flux-general/rf-inversion`
- Docs page: https://doitong.com/zh/developers/models/flux-general/rf-inversion

## Pricing

Price: **$0.025 / image**. Estimated from the typical cost of one run, per output (`num_images`). The quote is exactly what the run charges.

The full example input below costs $0.025 = 25 API credits (1 image × 25 API credits).

Prices are the upstream price in USD, paid from the API balance in API credits (1000 API credits = 1 USD). `POST https://api.doitong.com/v1/quote/flux-general/rf-inversion` with the same JSON body returns the exact price for that input; the quote is exactly what a run charges. Invalid input is never charged and failed or canceled requests are refunded automatically.

## Input parameters

Send either the canonical name or the native field name (not both). Canonical names are the same across models.

| Parameter | Canonical name | Type | Required | Default | Allowed values / range | Description |
|---|---|---|---|---|---|---|
| `prompt` |  | string | yes |  |  | 引导图像编辑的提示词。 |
| `image_size` |  | object {width, height} \| enum (string) | no |  | `square_hd`, `square`, `portrait_4_3`, `portrait_16_9`, `landscape_4_3`, `landscape_16_9` | 生成图像的尺寸。 |
| `num_inference_steps` |  | integer | no | `28` | 1 – 50 | 要执行的推理步数。 |
| `seed` |  | integer \| null | no |  |  | 用于生成可复现图像的种子：模型版本不变时，相同的提示词和种子会生成相同图像。 |
| `loras` |  | array of object {path, scale} | no | `[]` |  | 其组合效果用于生成图像的 LoRA，数量不限。 |
| `loras[].path` |  | string | yes |  |  | LoRA 权重的位置，以 URL 或路径指定。 |
| `loras[].scale` |  | object \| number | no | `1` |  | 合并到基础模型前应用于 LoRA 权重的缩放。提供形如 {"layer_name":layer_scale} 的字典可设置单独的层缩放；未指定的层使用 1.0。 |
| `control_loras` |  | array of object {path, scale, control_image_url, preprocess} | no | `[]` |  | 合并为组合配置、用于生成最终图像的控制图像 LoRA；数量不限。 |
| `control_loras[].path` |  | string | yes |  |  | LoRA 权重的位置，以 URL 或路径指定。 |
| `control_loras[].scale` |  | object \| number | no | `1` |  | 合并到基础模型前应用于 LoRA 权重的缩放。提供形如 {"layer_name":layer_scale} 的字典可设置单独的层缩放；未指定的层使用 1.0。 |
| `control_loras[].control_image_url` |  | string (image URL) | yes |  |  | 提供控制图像的图像 URL。 |
| `control_loras[].preprocess` |  | enum (string) | no | `None` | `canny`, `depth`, `None` | 应用于所提供图像的预处理方法。 |
| `controlnets` |  | array of object {path, config_url, variant, control_image_url, mask_image_url, mask_threshold, conditioning_scale, start_percentage, end_percentage} | no | `[]` |  | 用于图像生成的 ControlNet 配置，目前仅限单个 ControlNet。 |
| `controlnets[].path` |  | string | yes |  |  | ControlNet 权重位置，可指定为 URL 或路径。 |
| `controlnets[].config_url` |  | string \| null | no |  |  | 可选的 URL，指向 ControlNet 的 config.json 文件。 |
| `controlnets[].variant` |  | string \| null | no |  |  | 与 Hugging Face 仓库键配合使用的可选变体。 |
| `controlnets[].control_image_url` |  | string (image URL) | yes |  |  | 提供控制图像的图像 URL。 |
| `controlnets[].mask_image_url` |  | string (image URL) | no |  |  | 与控制图像关联的遮罩 URL。 |
| `controlnets[].mask_threshold` |  | number | no | `0.5` | 0.01 – 0.99 | 遮罩阈值。 |
| `controlnets[].conditioning_scale` |  | number | no | `1` | 0 – 2 | 合并到基础模型前应用于 ControlNet 权重的缩放。 |
| `controlnets[].start_percentage` |  | number | no | `0` | 0 – 1 | ControlNet 开始影响图像生成时所处的总时间步百分比。 |
| `controlnets[].end_percentage` |  | number | no | `1` | 0 – 1 | ControlNet 停止影响图像生成时所处的总时间步百分比。 |
| `controlnet_unions` |  | array of object {path, config_url, variant, controls} | no | `[]` |  | 用于图像生成的 ControlNet union 配置，受当前单个 ControlNet 限制。 |
| `controlnet_unions[].path` |  | string | yes |  |  | ControlNet 权重位置，可指定为 URL 或路径。 |
| `controlnet_unions[].config_url` |  | string \| null | no |  |  | 可选的 URL，指向 ControlNet 的 config.json 文件。 |
| `controlnet_unions[].variant` |  | string \| null | no |  |  | 与 Hugging Face 仓库键配合使用的可选变体。 |
| `controlnet_unions[].controls` |  | array of object {control_image_url, mask_image_url, control_mode, conditioning_scale, mask_threshold, start_percentage, end_percentage} | yes |  |  | 提供给 ControlNet 的控制图像及其关联模式。 |
| `controlnet_unions[].controls[].control_image_url` |  | string (image URL) | yes |  |  | 提供控制图像的图像 URL。 |
| `controlnet_unions[].controls[].mask_image_url` |  | string (image URL) | no |  |  | 与控制图像关联的遮罩 URL。 |
| `controlnet_unions[].controls[].control_mode` |  | enum (string) | yes |  | `canny`, `tile`, `depth`, `blur`, `pose`, `gray`, `low-quality` | Flux Controlnet Union 使用的控制模式。选项：canny 使用边缘引导生成；tile 使用图块引导；depth 使用灰度深度图引导；blur 模糊图像；pose 使用图像姿态引导生成；gray 将图像转为灰度；low-quality 生成低质量版本的图像。 |
| `controlnet_unions[].controls[].conditioning_scale` |  | number | no | `1` | 0 – 2 | 合并到基础模型前应用于 ControlNet 权重的缩放。 |
| `controlnet_unions[].controls[].mask_threshold` |  | number | no | `0.5` | 0.01 – 0.99 | 遮罩阈值。 |
| `controlnet_unions[].controls[].start_percentage` |  | number | no | `0` | 0 – 1 | ControlNet 开始影响图像生成时所处的总时间步百分比。 |
| `controlnet_unions[].controls[].end_percentage` |  | number | no | `1` | 0 – 1 | ControlNet 停止影响图像生成时所处的总时间步百分比。 |
| `easycontrols` |  | array of object {control_method_url, scale, image_url, image_control_type} | no | `[]` |  | 图像生成期间应用的 EasyControl 输入。 |
| `easycontrols[].control_method_url` |  | string | yes |  |  | 控制方法的 safetensor 权重 URL，或受支持的标识符：`canny`、`depth`、`hedsketch`、`inpainting`、`pose`、`seg`、`subject`、`ghibli`。 |
| `easycontrols[].scale` |  | number | no | `1` | 0 – 2 | 控制方法缩放因子。 |
| `easycontrols[].image_url` |  | string (image URL) | yes |  |  | 提供控制输入的图像 URL。 |
| `easycontrols[].image_control_type` |  | enum (string) | yes |  | `subject`, `spatial` | 图像控制模式；接受 `spatial` 或 `subject`。 |
| `fill_image` |  | object {fill_image_url} \| null | no |  |  | 引导生成并可为遮罩区域提供内容的输入图像。 |
| `fill_image.fill_image_url` |  | string (image URL) \| array of image URL | no | `[]` |  | 用于通过 redux 提示词填充的图像 URL。 |
| `guidance_scale` |  | number | no | `3.5` | 0 – 20 | 图像选择对提示词的遵循强度，以 CFG（Classifier Free Guidance）表示。 |
| `use_cfg_zero` |  | boolean | no | `false` |  | 启用 CFG-zero 初始化采样，说明见 https://arxiv.org/abs/2503.18886。 |
| `num_images` | `num_outputs` | integer | no | `1` | 1 – 10 | 设置要生成的图像数量；输出以流式传输时固定为 1。 |
| `enable_safety_checker` |  | boolean | no | `true` |  | 安全检查；对于被标记为不安全的图像，返回黑色图像替代。true 启用检查；false 仅对获授权账户禁用检查，未获授权的请求无论如何都会检查。 |
| `reference_image_url` |  | string (image URL) | no |  |  | 用于 Reference-Only 引导的图像 URL。 |
| `reference_strength` |  | number | no | `0.65` | -3 – 3 | reference_only 生成期间参考图像的影响程度；未提供参考图像时，此强度设置无效。 |
| `reference_start` |  | number | no | `0` | 0 – 1 | 参考引导起点，占全部时间步的百分比。 |
| `reference_end` |  | number | no | `1` | 0 – 1 | 参考引导终点，占全部时间步的百分比。 |
| `base_shift` |  | number | no | `0.5` | 0.01 – 5 | 应用于调度时间步的基线偏移。 |
| `max_shift` |  | number | no | `1.15` | 0.01 – 5 | 应用于调度时间步的最大偏移。 |
| `output_format` |  | enum (string) | no | `png` | `jpeg`, `png` | 结果图像的文件格式。 |
| `use_beta_schedule` |  | boolean | no | `false` |  | 控制是否使用 beta sigmas。 |
| `sigma_schedule` |  | string \| null | no |  |  | 去噪期间使用的 sigma 调度。 |
| `scheduler` |  | enum (string) | no | `euler` | `euler`, `dpmpp_2m` | 去噪期间使用的调度器。 |
| `negative_prompt` |  | string | no | `` |  | 默认使用 NAG 处理的负面提示词，用于抑制生成图像中的指定不需要特征。 |
| `nag_scale` |  | number | no | `3` | ≤ 10, > 1 | 由 NAG scale 控制的负面提示词规避程度：提高该值会使生成图像不那么接近负面描述。 |
| `nag_tau` |  | number | no | `2.5` | > 0 | 用于隐藏状态归一化的 NAG tau 设置；建议保持不变。提高该值会削弱归一化，并可能导致图像意外偏离原图。 |
| `nag_alpha` |  | number | no | `0.25` | ≤ 1, > 0 | NAG alpha 设置正面提示词重新引导归一化引导的程度，该引导结合了正面和负面提示词。最终权重在较低设置下使正面提示词影响更大，在较高设置下减少重新引导。 |
| `nag_end` |  | number | no | `0.25` | ≤ 1, > 0 | NAG 截止点，占生成步数的比例。NAG 按该初始比例运行后，FLUX 原始注意力处理器接管。 |
| `image_url` | `image` | string (image URL) | yes |  |  | 标识编辑输入的图像 URL。 |
| `controller_guidance_forward` |  | number | no | `0.6` | 0.01 – 3 | 用于生成结构化噪声的控制器引导（gamma）。 |
| `controller_guidance_reverse` |  | number | no | `0.75` | 0.01 – 3 | 设置 eta，即去噪控制器的引导值；设置接近 1 时，生成的图像与输入图像更相似。 |
| `reverse_guidance_start` |  | integer | no | `0` |  | 反向过程中引导的起始时间步。 |
| `reverse_guidance_end` |  | integer | no | `8` |  | 反向过程中引导的结束时间步。 |
| `reverse_guidance_schedule` |  | enum (string) | no | `constant` | `constant`, `linear_increase`, `linear_decrease` | 控制应用反向引导的调度。 |

File parameters (`reference_image_url`, `image`) take a public `https://` URL, a `data:` URI up to 10 MB, or the `file_url` of an upload from `POST /files`.

## Example input

Required parameters only:

```json
{
  "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
  "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}
```

A fuller example:

```json
{
  "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
  "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
}
```

## Run it

Set `DOITONG_API_KEY` to a key from https://doitong.com/developers/dashboard#keys. `?wait=20` returns the finished request in the same call when it is ready within 20 seconds; otherwise poll `GET /requests/{id}` (it also accepts `?wait=`), or pass `webhook_url`.

### curl

```bash
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/flux-general/rf-inversion?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"
```

### JavaScript

```javascript
const API = "https://api.doitong.com/v1";
const headers = {
  "Authorization": "Bearer " + process.env.DOITONG_API_KEY,
  "Content-Type": "application/json",
};

// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/flux-general/rf-inversion?wait=20", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);

// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
  res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
  request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
```

### Python

```python
import os
import requests

API = "https://api.doitong.com/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}

payload = {
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg",
}

# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/flux-general/rf-inversion", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
    raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])

# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
    request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
    raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
```

### MCP

The MCP server at `https://api.doitong.com/v1/mcp` exposes the tools `search_models`, `get_model`, `quote`, `run`, `get_request`, `cancel_request`, `list_requests`, `create_upload` and `get_account`. A `run` call for this model:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "run",
    "arguments": {
      "model_id": "flux-general/rf-inversion",
      "input": {
        "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
        "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
      },
      "wait_seconds": 20
    }
  }
}
```

## Response

Every call returns a request object. `status` is one of `queued`, `running`, `succeeded`, `failed`, `canceled`. `outputs` lists the generated files with URLs on our storage (kept forever, or 7 days with `?storage=temporary`; `storage` says which); `output` is the model's own result object with the same URLs.

```json
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "flux-general/rf-inversion",
  "status": "succeeded",
  "created_at": "2026-10-20T12:00:00Z",
  "started_at": "2026-10-20T12:00:02Z",
  "completed_at": "2026-10-20T12:00:09Z",
  "queue_position": null,
  "cost": {
    "credits": 25,
    "usd": "0.025",
    "charged": 25,
    "refunded": 0
  },
  "input": {
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  },
  "output": {
    "images": [
      {
        "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
        "width": 1024,
        "height": 768,
        "content_type": "image/jpeg"
      }
    ],
    "timings": {},
    "seed": 42,
    "has_nsfw_concepts": [
      false
    ],
    "prompt": "string"
  },
  "outputs": [
    {
      "type": "image",
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768,
      "stored": true
    }
  ],
  "error": null,
  "metrics": {
    "inference_seconds": 6.8
  },
  "urls": {
    "self": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
```

### Output fields (`output`)

| Field | Type | Description |
|---|---|---|
| `images` | array of object {url, width, height, content_type} | 生成图像的文件信息。 |
| `timings` | object |  |
| `seed` | integer | 图像生成种子；如果输入未提供种子，则包含随机选择的值，否则重复使用所提供的值。 |
| `has_nsfw_concepts` | array of boolean | 指示生成的图像中是否出现 NSFW 概念。 |
| `prompt` | string | 图像生成期间使用的提示词。 |

## Related models

- [FLUX.1 \[dev\] with Controlnets and Loras](https://doitong.com/developers/models/flux-general.md) (`flux-general`): $0.30 / image
- [FLUX.1 \[dev\] with Controlnets and Loras · Differential Diffusion](https://doitong.com/developers/models/flux-general/differential-diffusion.md) (`flux-general/differential-diffusion`): $0.138 / image
- [FLUX.1 \[dev\] with Controlnets and Loras · Image to Image](https://doitong.com/developers/models/flux-general/image-to-image.md) (`flux-general/image-to-image`): $0.15 / image
- [FLUX.1 \[dev\] with Controlnets and Loras · Inpainting](https://doitong.com/developers/models/flux-general/inpainting.md) (`flux-general/inpainting`): $0.192 / image
- [FLUX.1 Kontext \[pro\]](https://doitong.com/developers/models/flux-pro/kontext.md) (`flux-pro/kontext`): $0.04 / image
- [GPT Image 2.5 Edit](https://doitong.com/developers/models/openai/gpt-image-2.5/flare/edit.md) (`openai/gpt-image-2.5/flare/edit`): from $0.12 / image
- [Nano Banana 2 Edit](https://doitong.com/developers/models/nano-banana-2/edit.md) (`nano-banana-2/edit`): from $0.06 / image
- [Nano Banana Pro Edit](https://doitong.com/developers/models/nano-banana-pro/edit.md) (`nano-banana-pro/edit`): from $0.15 / image

## Links

- HTML page: https://doitong.com/developers/models/flux-general/rf-inversion
- All models and guides for AI agents: https://doitong.com/developers/llms.txt
- OpenAPI 3.1 with this model's typed request body: https://doitong.com/developers/openapi.json?model=flux-general/rf-inversion
- Errors: https://doitong.com/developers/docs/errors
- Model details as JSON: https://api.doitong.com/v1/models/flux-general/rf-inversion
