Flux-图片生成
概览
- 请求方法:
POST - 路径:
/v1/images/generations - 内容类型:
application/json - 说明:该请求格式与 OpenAI 的 DALL-E 模型请求格式一致。
支持的尺寸和比例
| 尺寸 | 比例 |
|---|---|
| 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 | application/json | 是 |
| Authorization | Bearer sk-xxxx | 是 |
请求体(JSON)
json
{
"prompt": "一幅详细的图像描绘了一个广阔的石器时代城市,城市中高耸的摩天大楼由巨石和骨头构成。这里热闹非凡,各种性别和种族的人们共同展现出原始人和原始女性的统一外貌。他们身穿商务服装,与史前背景形成鲜明对比。化石化的塔楼点缀着石质天际线,而人们则保留着原始的设计,身上披着毛皮,搭配现代的西装和领带。形成了现代生活与史前时代的美丽融合。",
"model": "flux-kontext-pro",
"size": "3:4",
"output_format": "png",
"seed": 12345,
"prompt_upsampling": true,
"safety_tolerance": 6
}参数说明
| 参数 | 类型 | 必填 | 默认 | 描述 |
|---|---|---|---|---|
| prompt | string | 是 | - | 所需图像的文本描述,最大1000(或4000)字符 |
| model | string | 是 | - | 模型名称;支持 flux、flux-dev、flux-pro、flux-pro-max、flux.1.1-pro、flux-kontext-max、flux-kontext-pro |
| size | string | 否 | 1:1 | 图片尺寸,支持 1:1,3:4,4:3,9:16,16:9,9:21,21:9 或 1024x1024 等数值格式(宽高32倍数) |
| output_format | string | 否 | png | jpeg 或 png |
| seed | integer | 否 | - | 随机种子 |
| prompt_upsampling | boolean | 否 | true | 是否启用提示词优化 |
| safety_tolerance | integer | 否 | 6 | 审核容忍度,0-6间,0最严格、6最宽松 |
返回示例(200)
json
{
"created": 1725007743,
"data": [
{
"revised_prompt": "A detailed image illustrating a sprawling Stone Age city with towering skyscrapers made from massive rocks and bones. The city is bustling with people of all genders and descents, such as Hispanic, Caucasian, South Asian, and Middle Eastern, unified in their appearance as primordial men and women. They are clad in business attire, contrasting significantly with the prehistoric backdrop. Fossilized towers adorn the stony skyline, while the people retain primitive designs, draped in pelts along with modern suits and ties, forming a beautiful blend of modern living with the prehistoric era.",
"url": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-ckj8cP1MmQK3ZdLPGoozEzD9/vv/img-l4C07hxN49jraolwGOXGc6Ce.png?st=2024-08-30T07%3A49%3A03Z&se=2024-08-30T09%3A49%3A03Z&sp=r&sv=2024-08-04&sr=b&rscd=inline&rsct=image/png&skoid=d505667d-d6c1-4a0a-bac7-5c84a87759f8&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-08-29T19%3A17%3A38Z&ske=2024-08-30T19%3A17%3A38Z&sks=b&skv=2024-08-04&sig=UA38MfIU62lG5JtT2GCOqHEseAqnDceoA3iNwhfS4Xk%3D"
}
]
}