FLUX 图像
- 文生图、单图编辑、多图参考
- 支持在提示词里用 bbox 精确控制版式
- 输出档位从 768 到 4K
认证
All endpoints authenticate with a Bearer token.
Get an API key: open the console and create one.
Add it to the request header:
Authorization: Bearer YOUR_OAIRoute_KEY请求结构
请求体是平铺的 JSON,创作字段与输出字段都在顶层,没有 content 数组包装。
The body is flat JSON: creative fields and output fields sit at the top level, with no content array wrapper.
支持的场景
| 场景 | 字段组合 |
|---|---|
| 文生图 | prompt |
| 单图编辑 | prompt + image(1 张) |
| 多图参考 | prompt + image(2 到 10 张) |
| 版式控制 | prompt 内含 bbox JSON 数组 |
参考图按顺序编号为 ref_image_0、ref_image_1,提示词里也可以写成 Image 1、Image 2。
| Scenario | Field combination |
|---|---|
| Text to image | prompt |
| Single-image edit | prompt + image (1 image) |
| Multi-image reference | prompt + image (2 to 10 images) |
| Layout control | A bbox JSON array inside prompt |
Reference images are numbered in order as ref_image_0, ref_image_1, and can also be referred to in the prompt as Image 1, Image 2.
请求参数
提交成功只返回任务 ID,不含图片本身。拿结果用 task_id 轮询获取任务状态,图片地址在 result.images[0].url,该地址会过期,请及时转存。
取值 flux-3-image。
场景描述或编辑指令。
不支持反向提示词,请正面描述想要的结果。可以在提示词里带 <tag> 元素引用与 bbox JSON 数组,用于控制版式或局部编辑。
参考图,1 到 10 张。公网地址或 Base64。超过 10 张返回 400。
传入即由文生图切换为编辑或多图参考。
画幅,默认 auto。
取值 21:9、2:1、16:9、3:2、7:5、4:3、5:4、1:1、4:5、3:4、5:7、2:3、9:16、1:2、9:21、auto,也接受 16x9 写法。
输出档位,取值 768sq、1k(默认)、1.5k、2k、4k,大小写不敏感。
768 等同 768sq。该字段同时决定计费档。
内容宽松度,取值 0 到 4,默认 2,数值越大越宽松。
允许生成前联网或检索图片,默认 true。必须是布尔值,传字符串 "false" 会返回 400。
只能为 1。需要多张请分多次提交。
A successful submission returns only the task ID, not the image itself. Poll Get task status with the task_id; the image URL is at result.images[0].url and expires, so copy it promptly.
Always flux-3-image.
A scene description or edit instruction.
Negative prompts aren't supported; describe the result you want positively. The prompt can carry <tag> elements and a bbox JSON array to control layout or local edits.
Reference images, 1 to 10. Public URLs or Base64. More than 10 returns a 400.
Passing these switches from text to image into an edit or multi-image reference.
Aspect ratio, default auto.
Values: 21:9, 2:1, 16:9, 3:2, 7:5, 4:3, 5:4, 1:1, 4:5, 3:4, 5:7, 2:3, 9:16, 1:2, 9:21, auto; the 16x9 spelling is also accepted.
Output tier: 768sq, 1k (default), 1.5k, 2k, 4k; case-insensitive.
768 is equivalent to 768sq. This field also determines the billing tier.
Content leniency, 0 to 4, default 2; higher is more permissive.
Allows online lookup or image retrieval before generation; defaults to true. Must be a boolean; passing the string "false" returns a 400.
Must be 1. Submit multiple times if you need more images.
不接受的字段
width、height、像素形式的 size(如 1024x1024)、seed、steps、guidance、output_format、negative_prompt、prompt_upsampling、mask_url 都会被拒绝并返回 400,不会静默忽略。
输出尺寸用 resolution 控制,形状用 aspect_ratio 控制。
width, height, pixel-form size (such as 1024x1024), seed, steps, guidance, output_format, negative_prompt, prompt_upsampling, and mask_url are all rejected with a 400 rather than silently ignored.
Control output dimensions with resolution and shape with aspect_ratio.
bbox 版式控制
bbox 是提示词字符串的一部分,不是独立参数。每个元素用 id、from、src_bbox、tgt_bbox、desc 描述。
坐标格式是 [top, left, bottom, right],即 [y1, x1, y2, x2],归一化到 0 到 1000,原点在左上角,不是像素值。
需要保留的区域也要写进 bbox,并在 desc 里说明保持不变。
bbox is part of the prompt string, not a separate parameter. Each element is described by id, from, src_bbox, tgt_bbox, and desc.
Coordinates are [top, left, bottom, right], i.e. [y1, x1, y2, x2], normalized to 0–1000 with the origin at the top left — not pixel values.
Regions to preserve must also be written into the bbox, with desc explaining that they stay unchanged.
Kontext 系列的差异
flux-kontext-pro 与 flux-kontext-max 支持 output_format、response_format、seed、prompt_upsampling、safety_tolerance(0 到 6),但不支持 resolution,输出固定在约 1MP。size 写像素时只会映射到最接近的支持比例,不保证精确尺寸。
flux-kontext-pro and flux-kontext-max support output_format, response_format, seed, prompt_upsampling, and safety_tolerance (0 to 6), but not resolution; output is fixed at about 1MP. A pixel size only maps to the nearest supported ratio and doesn't guarantee exact dimensions.
响应
提交成功返回受理结构:
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01K8SGYNNNVBQTXNR4MM964S7K"
}
]
}状态码,200 表示任务已受理。
本次提交的任务列表。
受理状态,提交成功时为 submitted。
任务 ID,用它轮询结果。
完成态返回:
{
"code": 200,
"data": {
"id": "task_01K8SGYNNNVBQTXNR4MM964S7K",
"status": "completed",
"progress": 100,
"result": {
"images": [
{ "url": ["https://cdn.oairoute.com/f/image/task_01K8_0.png"], "expires_at": 1763174708 }
]
},
"created": 1763088289,
"completed": 1763088302
}
}A successful submission returns an accepted structure:
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01K8SGYNNNVBQTXNR4MM964S7K"
}
]
}The status code; 200 means the task was accepted.
The list of tasks submitted this time.
The acceptance status; submitted on success.
The task ID; use it to poll for the result.
The completed state returns:
{
"code": 200,
"data": {
"id": "task_01K8SGYNNNVBQTXNR4MM964S7K",
"status": "completed",
"progress": 100,
"result": {
"images": [
{ "url": ["https://cdn.oairoute.com/f/image/task_01K8_0.png"], "expires_at": 1763174708 }
]
},
"created": 1763088289,
"completed": 1763088302
}
}错误码
| HTTP | 含义 |
|---|---|
| 400 | 参数错误,type 为 invalid_request_error |
| 401 | Token 缺失或无效,type 为 authentication_error |
| 402 | 余额不足,type 为 payment_required |
| 429 | 触发限流 |
| HTTP | Meaning |
|---|---|
| 400 | Invalid parameters, with type invalid_request_error |
| 401 | Token missing or invalid, with type authentication_error |
| 402 | Insufficient balance, with type payment_required |
| 429 | Rate limit hit |
For more status codes and retry guidance see Error codes and rate limits; for troubleshooting steps on common errors see the FAQ.
支持的模型列表
| 模型 ID | 定位 |
|---|---|
flux-3-image | 主力型号,支持文生图、编辑、多图参考与版式控制 |
flux-kontext 系列走同一路径但参数不同,见下方差异说明。
GET https://api.oairoute.com/api/pricing。| Model ID | Positioning |
|---|---|
flux-3-image | The main model; supports text to image, edits, multi-image reference, and layout control |
The flux-kontext series uses the same path with different parameters; see the differences above.
GET https://api.oairoute.com/api/pricing.