FLUX.1 [dev] with Controlnets and Loras
集成
模型 id
flux-general
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://vit.doitong.com/api/v1/run/flux-general?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"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://vit.doitong.com/api/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://vit.doitong.com/api/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?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"
}),
});
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 + ")");
import os
import requests
API = "https://vit.doitong.com/api/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",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/flux-general", 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"])
# 1. Connect once (Claude Code; Cursor, VS Code, Claude Desktop: https://doitong.com/zh/developers/docs/mcp)
claude mcp add --transport http doitong-models https://vit.doitong.com/api/v1/mcp \
--header "Authorization: Bearer $DOITONG_API_KEY"
# 2. Your agent calls the "run" tool with:
{
"model_id": "flux-general",
"input": {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}
}
通过 Doitong API 调用 FLUX.1 [dev] with Controlnets and Loras 模型(flux-general)。智能体文档:https://doitong.com/zh/developers/models/flux-general.md
POST https://vit.doitong.com/api/v1/run/flux-general?wait=20
Authorization: Bearer $DOITONG_API_KEY
Content-Type: application/json
{
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}
如果响应状态为 "queued" 或 "running",请轮询 GET https://vit.doitong.com/api/v1/requests/REQUEST_ID?wait=20,直到状态变为 "succeeded";文件位于 outputs[].url。使用相同请求体 POST https://vit.doitong.com/api/v1/quote/flux-general,可在运行前返回确切价格。
此请求: ≈$0.30 300 API 积分 在此页面运行
你的新 API 密钥。 它仅在此时显示,并且已填入下方的代码和 API 密钥字段中。请妥善保密:切勿将其放入在浏览器中运行的代码。
构建请求
控件根据模型架构生成。更改控件时,代码和价格会同步更新。
POST
/run/flux-general?wait=20
报价 → $0.30
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://vit.doitong.com/api/v1/run/flux-general?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"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://vit.doitong.com/api/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://vit.doitong.com/api/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?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"
}),
});
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 + ")");
import os
import requests
API = "https://vit.doitong.com/api/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",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/flux-general", 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"])
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "run",
"arguments": {
"model_id": "flux-general",
"input": {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
},
"wait_seconds": 20
}
}
}
关于 FLUX.1 [dev] with Controlnets and Loras
根据 `prompt` 生成图像,并支持多种条件控制方式:`loras`、`control_loras`、`controlnets`、`controlnet_unions`、`ip_adapters` 和 `easycontrols`,以及用于蒙版区域的 `fill_image`。还支持 `reference_image_url`、负面提示词,以及 euler 或 dpmpp_2m 调度器选择。每次调用最多生成 10 张图像,格式为 png 或 jpeg。
参数
发送规范名称或原生名称之一,不要同时发送两者。 规范名称
名称类型
默认值允许值
描述
prompt必填
类型string
指导图像生成的提示词。
image_size可选
类型object
square_hdsquareportrait_4_3portrait_16_9landscape_4_3landscape_16_9
生成图像的尺寸。
num_inference_steps可选
类型integer
默认值28
1 – 50
要执行的推理步数。
seed可选
类型integer | null
用于生成可复现图像的种子:模型版本不变时,相同的提示词和种子会生成相同图像。
loras可选
类型object[]
默认值[]
其组合效果用于生成图像的 LoRA,数量不限。
loras[].path必填
类型string
LoRA 权重的位置,以 URL 或路径指定。
loras[].scale可选
类型object | number
默认值1
合并到基础模型前应用于 LoRA 权重的缩放。提供形如 {"layer_name":layer_scale} 的字典可设置单独的层缩放;未指定的层使用 1.0。
control_loras可选
类型object[]
默认值[]
合并为组合配置、用于生成最终图像的控制图像 LoRA;数量不限。
control_loras[].path必填
类型string
LoRA 权重的位置,以 URL 或路径指定。
control_loras[].scale可选
类型object | number
默认值1
合并到基础模型前应用于 LoRA 权重的缩放。提供形如 {"layer_name":layer_scale} 的字典可设置单独的层缩放;未指定的层使用 1.0。
control_loras[].control_image_url必填
类型url · image
提供控制图像的图像 URL。
control_loras[].preprocess可选
类型enum
默认值None
cannydepthNone
应用于所提供图像的预处理方法。
controlnets可选
类型object[]
默认值[]
用于图像生成的 ControlNet 配置,目前仅限单个 ControlNet。
controlnets[].path必填
类型string
ControlNet 权重位置,可指定为 URL 或路径。
controlnets[].config_url可选
类型string | null
可选的 URL,指向 ControlNet 的 config.json 文件。
controlnets[].variant可选
类型string | null
与 Hugging Face 仓库键配合使用的可选变体。
controlnets[].control_image_url必填
类型url · image
提供控制图像的图像 URL。
controlnets[].mask_image_url可选
类型url · image
与控制图像关联的遮罩 URL。
controlnets[].mask_threshold可选
类型number
默认值0.5
0.01 – 0.99
遮罩阈值。
controlnets[].conditioning_scale可选
类型number
默认值1
0 – 2
合并到基础模型前应用于 ControlNet 权重的缩放。
controlnets[].start_percentage可选
类型number
默认值0
0 – 1
ControlNet 开始影响图像生成时所处的总时间步百分比。
controlnets[].end_percentage可选
类型number
默认值1
0 – 1
ControlNet 停止影响图像生成时所处的总时间步百分比。
controlnet_unions可选
类型object[]
默认值[]
用于图像生成的 ControlNet union 配置,受当前单个 ControlNet 限制。
controlnet_unions[].path必填
类型string
ControlNet 权重位置,可指定为 URL 或路径。
controlnet_unions[].config_url可选
类型string | null
可选的 URL,指向 ControlNet 的 config.json 文件。
controlnet_unions[].variant可选
类型string | null
与 Hugging Face 仓库键配合使用的可选变体。
controlnet_unions[].controls必填
类型object[]
提供给 ControlNet 的控制图像及其关联模式。
controlnet_unions[].controls[].control_image_url必填
类型url · image
提供控制图像的图像 URL。
controlnet_unions[].controls[].mask_image_url可选
类型url · image
与控制图像关联的遮罩 URL。
controlnet_unions[].controls[].control_mode必填
类型enum
cannytiledepthblurposegraylow-quality
Flux Controlnet Union 使用的控制模式。选项:canny 使用边缘引导生成;tile 使用图块引导;depth 使用灰度深度图引导;blur 模糊图像;pose 使用图像姿态引导生成;gray 将图像转为灰度;low-quality 生成低质量版本的图像。
controlnet_unions[].controls[].conditioning_scale可选
类型number
默认值1
0 – 2
合并到基础模型前应用于 ControlNet 权重的缩放。
controlnet_unions[].controls[].mask_threshold可选
类型number
默认值0.5
0.01 – 0.99
遮罩阈值。
controlnet_unions[].controls[].start_percentage可选
类型number
默认值0
0 – 1
ControlNet 开始影响图像生成时所处的总时间步百分比。
controlnet_unions[].controls[].end_percentage可选
类型number
默认值1
0 – 1
ControlNet 停止影响图像生成时所处的总时间步百分比。
ip_adapters可选
类型object[]
默认值[]
图像生成期间应用的 IP-Adapter。
ip_adapters[].path必填
类型string
IP-Adapter 在 Hugging Face 上的位置。
ip_adapters[].subfolder可选
类型string | null
包含 ip_adapter 权重的子文件夹。
ip_adapters[].weight_name可选
类型string | null
IP-Adapter 权重的 Safetensors 文件名。
ip_adapters[].image_encoder_path必填
类型string
IP-Adapter 图像编码器的位置,例如 'openai/clip-vit-large-patch14'。
ip_adapters[].image_encoder_subfolder可选
类型string | null
包含图像编码器权重的子文件夹。
ip_adapters[].image_encoder_weight_name可选
类型string | null
图像编码器名称。
ip_adapters[].image_url必填
类型url · image
提供给 IP-Adapter 的条件图像 URL。
ip_adapters[].mask_image_url可选
类型url · image
与控制图像关联的遮罩 URL。
ip_adapters[].mask_threshold可选
类型number
默认值0.5
0.01 – 0.99
遮罩阈值。
ip_adapters[].scale必填
类型number
IP-Adapter 缩放因子。
easycontrols可选
类型object[]
默认值[]
图像生成期间应用的 EasyControl 输入。
easycontrols[].control_method_url必填
类型string
控制方法的 safetensor 权重 URL,或受支持的标识符:`canny`、`depth`、`hedsketch`、`inpainting`、`pose`、`seg`、`subject`、`ghibli`。
easycontrols[].scale可选
类型number
默认值1
0 – 2
控制方法缩放因子。
easycontrols[].image_url必填
类型url · image
提供控制输入的图像 URL。
easycontrols[].image_control_type必填
类型enum
subjectspatial
图像控制模式;接受 `spatial` 或 `subject`。
fill_image可选
类型object
引导生成并可为遮罩区域提供内容的输入图像。
fill_image.fill_image_url可选
类型url · image
默认值[]
用于通过 redux 提示词填充的图像 URL。
guidance_scale可选
类型number
默认值3.5
0 – 20
图像选择对提示词的遵循强度,以 CFG(Classifier Free Guidance)表示。
real_cfg_scale可选
类型number
默认值3.5
0 – 5
图像选择对提示词的遵循强度,以 CFG(Classifier Free Guidance)表示。
use_real_cfg可选
类型boolean
默认值false
经典 CFG 开关,与 XLabs IP-Adapter v1 一起使用时自动启用。引导行为与 SD1.5 和 SDXL 等模型一致。
use_cfg_zero可选
类型boolean
默认值false
启用 CFG-zero 初始化采样,说明见 https://arxiv.org/abs/2503.18886。
num_images可选
num_outputs
类型integer
默认值1
1 – 10
设置要生成的图像数量;输出以流式传输时固定为 1。
enable_safety_checker可选
类型boolean
默认值true
安全检查;对于被标记为不安全的图像,返回黑色图像替代。true 启用检查;false 仅对获授权账户禁用检查,未获授权的请求无论如何都会检查。
reference_image_url可选
类型url · image
用于 Reference-Only 引导的图像 URL。
reference_strength可选
类型number
默认值0.65
-3 – 3
reference_only 生成期间参考图像的影响程度;未提供参考图像时,此强度设置无效。
reference_start可选
类型number
默认值0
0 – 1
参考引导起点,占全部时间步的百分比。
reference_end可选
类型number
默认值1
0 – 1
参考引导终点,占全部时间步的百分比。
base_shift可选
类型number
默认值0.5
0.01 – 5
应用于调度时间步的基线偏移。
max_shift可选
类型number
默认值1.15
0.01 – 5
应用于调度时间步的最大偏移。
output_format可选
类型enum
默认值png
jpegpng
结果图像的文件格式。
use_beta_schedule可选
类型boolean
默认值false
控制是否使用 beta sigmas。
sigma_schedule可选
类型string | null
去噪期间使用的 sigma 调度。
scheduler可选
类型enum
默认值euler
eulerdpmpp_2m
去噪期间使用的调度器。
negative_prompt可选
类型string
默认值
默认使用 NAG 处理的负面提示词,用于抑制生成图像中的指定不需要特征。
nag_scale可选
类型number
默认值3
≤ 10> 1
由 NAG scale 控制的负面提示词规避程度:提高该值会使生成图像不那么接近负面描述。
nag_tau可选
类型number
默认值2.5
> 0
用于隐藏状态归一化的 NAG tau 设置;建议保持不变。提高该值会削弱归一化,并可能导致图像意外偏离原图。
nag_alpha可选
类型number
默认值0.25
≤ 1> 0
NAG alpha 设置正面提示词重新引导归一化引导的程度,该引导结合了正面和负面提示词。最终权重在较低设置下使正面提示词影响更大,在较高设置下减少重新引导。
nag_end可选
类型number
默认值0.25
≤ 1> 0
NAG 截止点,占生成步数的比例。NAG 按该初始比例运行后,FLUX 原始注意力处理器接管。
必填
规范名称,也可接受
文件参数接受公开的 https:// URL、最大 10 MB 的 data: URI,或上传文件的 file_url。 文件
输出
GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
"id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
"object": "request",
"model": "flux-general",
"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": 300,
"usd": "0.30",
"charged": 300,
"refunded": 0
},
"input": {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
},
"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://vit.doitong.com/api/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
"cancel": "https://vit.doitong.com/api/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
}
}
你的文件,由你选择每个 outputs[].url 都是存储中的副本:可永久保存(按 GB-月付费),也可免费保存 7 天,由账户设置或 ?storage= 决定。
每个模型的结构相同图像、视频和音频均包含 type、url、content_type、width、height 和 duration。output 是模型自身的结果对象。
输出字段
- images
- array of object {url, width, height, content_type}生成图像的文件信息。
- timings
- object
- seed
- integer图像生成种子;如果输入未提供种子,则包含随机选择的值,否则重复使用所提供的值。
- has_nsfw_concepts
- array of boolean指示生成的图像中是否出现 NSFW 概念。
- prompt
- string图像生成期间使用的提示词。
其他 FLUX.1 [dev] with Controlnets and Loras 变体
更多模型:文生图
对于 AI 代理:此页面的 Markdown 版本位于 https://doitong.com/zh/developers/models/flux-general.md. 所有模型和指南: https://doitong.com/developers/llms.txt







