# FLUX.1 Kontext [Pro]

**方法**: `POST`
**路径**: `/fal-ai/flux-pro/kontext`

用于生成图片的文本描述（必须）

## 请求参数

### Header 参数

```text
Content-Type
string
可选
示例:
application/json
Authorization
string
可选
默认值:
Bearer {{YOUR_API_KEY}}
```

### Body 参数 application/json

```text
prompt
string
必需
用于生成图片的文本描述（必须）
seed
integer
可选
随机种子，设置相同的 seed 和 prompt 会输出相同的图片（可选）
guidance_scale
number
可选
CFG 指导强度，决定生成图片是否更贴合 prompt，默认值3.5（可选）
默认值:
3.5
sync_mode
boolean
可选
同步模式，若为 true，则直接返回图片内容（可选）
num_images
integer
可选
生成图片数量，默认为1（可选）
默认值:
1
safety_tolerance
enum<string>
可选
内容安全容忍度，1最严格，6最宽松，默认2（API专有，可选）
枚举值:
1
2
3
4
5
6
默认值:
2
output_format
enum<string>
可选
图片输出格式，支持 jpeg 或 png，默认 jpeg（可选）
枚举值:
jpeg
png
默认值:
jpeg
aspect_ratio
enum<string>
可选
图片输出宽高比，默认 1:1（可选）
枚举值:
21:9
16:9
4:3
3:2
1:1
2:3
3:4
9:16
9:21
默认值:
1:1
示例
{
"prompt"
:
"string"
,
"seed"
:
0
,
"guidance_scale"
:
3.5
,
"sync_mode"
:
true
,
"num_images"
:
1
,
"safety_tolerance"
:
"2"
,
"output_format"
:
"jpeg"
,
"aspect_ratio"
:
"1:1"
}
```

## 请求示例代码

### Shell

```bash
curl --location --request POST '/fal-ai/flux-pro/kontext' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "prompt": "string",
    "seed": 0,
    "guidance_scale": 3.5,
    "sync_mode": true,
    "num_images": 1,
    "safety_tolerance": "2",
    "output_format": "jpeg",
    "aspect_ratio": "1:1"
}'
```

## 返回响应

### 🟢 200 成功

**内容类型**: `application/json`

#### 响应结构

```text
status
string
必需
request_id
string
必需
response_url
string
必需
status_url
string
必需
cancel_url
string
必需
queue_position
integer
必需
```

#### 示例

```json
{
    "status": "IN_QUEUE",
    "request_id": "551a32da-52b2-4be8-bf2f-bfb7cce2b324",
    "response_url": "https://queue.fal.run/fal-ai/flux-1/requests/551a32da-52b2-4be8-bf2f-bfb7cce2b324",
    "status_url": "https://queue.fal.run/fal-ai/flux-1/requests/551a32da-52b2-4be8-bf2f-bfb7cce2b324/status",
    "cancel_url": "https://queue.fal.run/fal-ai/flux-1/requests/551a32da-52b2-4be8-bf2f-bfb7cce2b324/cancel",
    "queue_position": 0
}
```
