跳转至

Flux生图

MaaS_Flux_Pro_1.1 / MaaS_Flux.1_Kontext 模型

创建生图任务

请求路径

POST https://genaiapi.cloudsway.net/v1/ai/{endpoint}/flux/image/generate

入参

MaaS_Flux_Pro_1.1 图片生成

参数名 类型 默认值 是否必填 描述
prompt string 所需图像的文字描述
width integer 1024 图像宽度(以像素为单位)
height integer 1024 图像高度(以像素为单位)
prompt_upsampling boolean FALSE 增强提示以获得更好的结果
seed integer null 可重复结果的种子。接受任何整数
safety_tolerance integer 2 内容审核级别。值范围从 0(最严格)到 6(较宽松)
output_format string “jpeg” 输出图像的所需格式。可以是“jpeg”或“png”。
webhook_url string null 异步完成通知的 URL。必须是有效的 HTTP/HTTPS URL
webhook_secret string null webhook 签名验证的密钥,在X-Webhook-Secret标头中发送

MaaS_Flux.1_Kontext 图片生成

说明:MaaS_Flux.1_Kontext 默认创建 1024x1024 的图像。用于aspect_ratio在保持总像素不变的情况下调整尺寸。

参数名 类型 默认值 是否必填 描述
prompt string 所需图像的文字描述
aspect_ratio string "1:1" 所需的宽高比(例如“16:9”)。所有输出总计约为 1MP。支持 3:7 至 7:3 的比例
seed integer null 用于可重复性的种子。如果null,则使用随机种子。接受任何整数
prompt_upsampling boolean FALSE 如果为 true,则对提示执行上采样
safety_tolerance integer 2 输入和输出的审核级别。值范围从 0(最严格)到 6(较宽松)
output_format string “jpeg” 输出图像的所需格式。可以是“jpeg”或“png”。
webhook_url string null 异步完成通知的 URL。必须是有效的 HTTP/HTTPS URL
webhook_secret string null webhook 签名验证的密钥,在X-Webhook-Secret标头中发送

MaaS_Flux.1_Kontext 图片编辑

说明:MaaS_Flux.1_Kontext 会尝试尽可能接近输入图像的尺寸(四舍五入为 32 的倍数)。aspect_ratio如有需要,请使用此方法覆盖此行为。

参数名 类型 默认值 是否必填 描述
prompt string 所需图像的文字描述
input_image string 用作参考的 Base64 编码图像。最大支持 20MB 或 2000 万像素
aspect_ratio string "1:1" 所需的宽高比(例如“16:9”)。所有输出总计约为 1MP。支持 3:7 至 7:3 的比例
seed integer null 用于可重复性的种子。如果null,则使用随机种子。接受任何整数
prompt_upsampling boolean FALSE 如果为 true,则对提示执行上采样
safety_tolerance integer 2 输入和输出的审核级别。值范围从 0(最严格)到 6(较宽松)
output_format string “jpeg” 输出图像的所需格式。可以是“jpeg”或“png”。
webhook_url string null 异步完成通知的 URL。必须是有效的 HTTP/HTTPS URL
webhook_secret string null webhook 签名验证的密钥,在X-Webhook-Secret标头中发送

出参

{
    "id": "6b7db656-56f2-484d-9aea-bdd9c447b8db",
    "polling_url": "https://genaiapi.cloudsway.net/v1/ai/{endpoint}/flux/get_result?id=6b7db656-56f2-484d-9aea-bdd9c447b8db"
}

调用示例

curl --location --request POST 'https://genaiapi.cloudsway.net/v1/ai/{endpoint}/flux/image/generate' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {key}' \
--data-raw '{
    "prompt": "A futuristic city skyline at sunset with flying cars",
    "width": 1024,
    "height": 1024
}'

获取结果

请求路径

GET https://genaiapi.cloudsway.net/v1/ai/{endpoint}/flux/get_result?id={id}

出参

{
    "id": "c34d8d13-b91d-4cea-b6d7-ec14a392d813",
    "result": {
        "seed": 1994028133,
        "prompt": "A futuristic city skyline at sunset with flying cars",
        "sample": "https://delivery-us1.bfl.ai/results/84/845643e5cfce52/e5cfce526bf94348b2d68e9f0fedb35c/sample.jpeg?se=2025-08-21T03%3A54%3A06Z&sp=r&sv=2024-11-04&sr=b&rsct=image/jpeg&sig=Pypqewv9SKRhnou8qoZGXQwUn5a8idtB3gn2DXZQbbs%3D",
        "duration": 2.1276044845581055,
        "end_time": 1.7557478461223414E9,
        "start_time": 1.755747843994737E9
    },
    "status": "Ready"
}

MaaS-Flux-1-schnell模型

创建生图任务

生图任务是异步完成

公共信息

参数 描述 示例
basePath 调用mass api的基础路径,包含/v1/ai固定路径 https://genaiapi.cloudsway.net/v2/ai
endpointPath 调用mass api的生成的一段随机路径
AccessKey 调用mass api的accessKey RWxxxxxxxx0Gd
taskId The task ID for asynchronous video processing tasks 1234abcd

请求方法

POST

请求路径

{basePath}/v2/ai/{endpointPath}/images/generations

参数 描述 示例
Authorization AccessKey
Bearer ${AccessKey}
Bearer RWxxxxxxxx0Gd

请求body

字段名 类型 是否必填 描述 示例值
prompts string 正向提示词 A fruit basket containing dragon fruit, mango, guava, apple, and banana.
batchsize int 出图数量 限制范围:1-8 default:1 1
aspect_ratio String 宽高比 支持的值:1:1、2:3、3:2、3:4、4:3、16:9、9:16 1:1 对应 1024:1024
2:3 对应 512:768
3:2 对应 768:512
3:4 对应 768:1024
4:3 对应 1024:768
16:9 对应 1280:720
9:16 对应 720:1280
step int 步数 限制范围:4-10 4
seed int 随机种子
default:0
0

返回值

字段名 类型 描述 示例值
status String 状态值 success
taskId String 任务id

示例

请求

curl --request POST \
--url https://genaiapi.cloudsway.net/v2/ai/lXynAhfbAiD/images/generations \
--header 'Authorization: Bearer ${AccessKey}' \
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \
--header 'content-type: application/json' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--data-raw '{
"prompts": "A fruit basket containing dragon fruit, mango, guava, apple, and banana.",
"aspect_ratio": "2:3",
"batchsize": "2",
"step": 10
}'

返回值

{
  "status": "success",
  "taskId": "3374b3b0-d069-4831-a76b-ebab4df14457"
}

查看任务信息

请求方法

GET

请求路径

{basePath}/v2/ai/{endpointPath}/images/tasks/{taskId}

请求header
参数 描述 示例
Authorization AccessKey
Bearer ${AccessKey}
Bearer RWxxxxxxxx0Gd

请求参数

字段名 类型 是否必填 描述 示例值
taskId String 任务id 3374b3b0-d069-4831-a76b-ebab4df14457

返回值

字段名 类型 描述 示例值
status String 任务状态信息
completed boolean 是否完成
imageUrls list 图片地址集合

示例

请求

curl --location --request GET 'https://genaiapi.cloudsway.net/v2/ai/lXynAhfbOiD/images/tasks/3374b3b0-d069-4831-a76b-ebab4df14457 ' \
--header 'Authorization: Bearer ${AccessKey}' \
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \
--header 'content-type: application/json' \
--header 'Accept: */*' \
--header 'Connection: keep-alive' \
--data-raw ''

返回值

{
  "status": "completed",
  "completed": true,
  "imageUrls": [
    "http://xxxx.png"
  ]
}