Flux-图片编辑
概览
- 请求方法:
POST - 路径:
/v1/images/edits - 内容类型:
multipart/form-data - 说明:该接口使用FormData参数请求,并非JSON格式参数。
支持的尺寸和比例
| 尺寸 | 比例 |
|---|---|
| 1024x1024 | 1:1 |
| 512x1024 | 1:2 |
| 1024x512 | 2:1 |
| 768x512 | 3:2 |
| 512x768 | 2:3 |
| 960x1280 | 3:4 |
| 1280x960 | 4:3 |
| 720x1280 | 9:16 |
| 1280x720 | 16:9 |
| 576x1344 | 9:21 |
| 1344x576 | 21:9 |
认证方式
Authorization: Bearer sk-xxx(必选)
请求示例
Header
| Header | 示例 | 必填 |
|---|---|---|
| Content-Type | multipart/form-data | 是 |
| Authorization | Bearer sk-xxxx | 是 |
表单字段
| 参数 | 类型 | 必填 | 示例 | 说明 |
|---|---|---|---|---|
| image | file 或 array | 是 | @otter.png | 源图像,最多 4 张,png/jpeg,小于 5MB |
| prompt | string | 是 | 帮我把他的衣服换成粉色 | 提示词,最大1000字符 |
| model | string | 否 | flux-kontext-pro | 模型名称,支持 flux-kontext-pro/flux-kontext-max |
| output_format | string | 否 | png | 输出格式,png/jpeg |
| size | string | 否 | 9:16 | 目标比例,可传 1:1、3:4 等 |
| seed | integer | 否 | 12345 | 随机种子 |
| prompt_upsampling | boolean | 否 | true | 是否优化提示词 |
| safety_tolerance | integer | 否 | 6 | 审核容忍度,0-6 |
curl 示例
bash
curl -X POST "https://api.gpt.ge/v1/images/edits" \
-H "Authorization: Bearer sk-xxxx" \
-F "image=@otter.png" \
-F "prompt=一只可爱的海獭宝宝戴着贝雷帽。" \
-F "model=flux-kontext-pro" \
-F "size=1024x1024"返回示例(200)
json
{
"created": 1589478378,
"data": [
{ "url": "https://..." },
{ "url": "https://..." }
]
}