跳至正文
EN
Black Forest Labs · 模型接口

FLUX.2 API

FLUX.2 API 的模型能力、计价规格、请求参数和接入示例。使用 VezAPI 账号密钥统一接入。

文生图图生图

FLUX.2 API 接入文档

使用 VezAPI 密钥接入 FLUX.2。下列操作共用同一个账号余额和鉴权方式。

服务地址: https://api.vezapi.com
请求头使用 Authorization: Bearer YOUR_VEZAPI_KEY。每次提交使用唯一的 Idempotency-Key,查询同一笔提交时才复用。

Flux-2 图生图

POST/api/v1/jobs/createTask

模型标识: flux-2/flex-image-to-image

参数类型说明与限制
model
必填
string

用于生成的模型名称。必填字段。 - 此端点必须使用 `flux-2/flex-image-to-image`

可选值:"flux-2/flex-image-to-image"

默认:"flux-2/flex-image-to-image"

callBackUrl
可选
string

接收生成任务完成更新的 URL。可选但建议在生产环境中使用。 - 当生成完成时,系统将向此 URL POST 任务状态和结果 - 回调包含生成的内容 URL 和任务信息 - 您的回调端点应接受包含结果的 JSON 负载的 POST 请求 - 或者,使用获取任务详情端点轮询任务状态 - 为确保回调安全性,请参阅 [Webhook 校验指南](/cn/common-api/webhook-verification) 了解签名验证实现方法

input
可选
object

生成任务的输入参数

input.input_urls
必填
array

输入参考图像(1-8 张)。(上传后的文件 URL,非文件内容;支持类型:image/jpeg、image/png、image/webp;最大大小:10.0MB)

maxItems: 8

input.prompt
必填
string

长度必须在 3-5000 字符之间。(最大长度:5000 字符)

maxLength: 5000

input.aspect_ratio
必填
string

必填。生成图像的宽高比。选择 `auto` 可匹配首张输入图像的比例(需传入输入图像)。

可选值:"1:1", "4:3", "3:4", "16:9", "9:16", "3:2", "2:3", "auto"

input.resolution
必填
string

必填。输出图像分辨率。

可选值:"1K", "2K"

input.nsfw_checker
可选
boolean

默认 false。为 false 时不额外进行内容过滤,结果由模型直接返回。

请求示例
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "flux-2/flex-image-to-image",
  "input": {
    "input_urls": [
      "https://example.com/input.png",
      "https://example.com/input.png"
    ],
    "prompt": "Replace the can in image 2 with the can from image 1",
    "aspect_ratio": "1:1",
    "resolution": "1K"
  }
}'
返回值与错误

HTTP 200

请求成功

参数类型说明与限制
code
可选
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

可选值:200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

msg
可选
string

Response message, error description upon failure

data
必填
object
data.taskId
必填
string

The task ID can be used with the "Get Task Details" endpoint to query the task status.

Flux-2 文生图

POST/api/v1/jobs/createTask

模型标识: flux-2/flex-text-to-image

参数类型说明与限制
model
必填
string

用于生成的模型名称。必填字段。 - 此端点必须使用 `flux-2/flex-text-to-image`

可选值:"flux-2/flex-text-to-image"

默认:"flux-2/flex-text-to-image"

callBackUrl
可选
string

接收生成任务完成更新的 URL。可选但建议在生产环境中使用。 - 当生成完成时,系统将向此 URL POST 任务状态和结果 - 回调包含生成的内容 URL 和任务信息 - 您的回调端点应接受包含结果的 JSON 负载的 POST 请求 - 或者,使用获取任务详情端点轮询任务状态 - 为确保回调安全性,请参阅 [Webhook 校验指南](/cn/common-api/webhook-verification) 了解签名验证实现方法

input
可选
object

生成任务的输入参数

input.prompt
必填
string

长度必须在 3-5000 字符之间。(最大长度:5000 字符)

maxLength: 5000

input.aspect_ratio
必填
string

必填。生成图像的宽高比。

可选值:"1:1", "4:3", "3:4", "16:9", "9:16", "3:2", "2:3"

input.resolution
必填
string

必填。输出图像分辨率。

可选值:"1K", "2K"

input.nsfw_checker
可选
boolean

默认 false。为 false 时不额外进行内容过滤,结果由模型直接返回。

请求示例
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "flux-2/flex-text-to-image",
  "input": {
    "prompt": "A humanoid figure with a vintage television set for a head, featuring a green-tinted screen displaying a `Hello FLUX.2` writing in ASCII font. The figure is wearing a yellow raincoat, and there are various wires and components attached to the television. The background is cloudy and indistinct, suggesting an outdoor setting",
    "aspect_ratio": "1:1",
    "resolution": "1K"
  }
}'
返回值与错误

HTTP 200

请求成功

参数类型说明与限制
code
可选
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

可选值:200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

msg
可选
string

Response message, error description upon failure

data
必填
object
data.taskId
必填
string

The task ID can be used with the "Get Task Details" endpoint to query the task status.

Flux-2 Pro 图生图

POST/api/v1/jobs/createTask

模型标识: flux-2/pro-image-to-image

参数类型说明与限制
model
必填
string

用于生成的模型名称。必填字段。 - 此端点必须使用 `flux-2/pro-image-to-image`

可选值:"flux-2/pro-image-to-image"

默认:"flux-2/pro-image-to-image"

callBackUrl
可选
string

接收生成任务完成更新的 URL。可选但建议在生产环境中使用。 - 当生成完成时,系统将向此 URL POST 任务状态和结果 - 回调包含生成的内容 URL 和任务信息 - 您的回调端点应接受包含结果的 JSON 负载的 POST 请求 - 或者,使用获取任务详情端点轮询任务状态 - 为确保回调安全性,请参阅 [Webhook 校验指南](/cn/common-api/webhook-verification) 了解签名验证实现方法

input
可选
object

生成任务的输入参数

input.input_urls
必填
array

输入参考图像(1-8 张)。(上传后的文件 URL,非文件内容;支持类型:image/jpeg、image/png、image/webp;最大大小:10.0MB)

maxItems: 8

input.prompt
必填
string

长度必须在 3-5000 字符之间。(最大长度:5000 字符)

maxLength: 5000

input.aspect_ratio
必填
string

必填。生成图像的宽高比。选择 `auto` 可匹配首张输入图像的比例(需传入输入图像)。

可选值:"1:1", "4:3", "3:4", "16:9", "9:16", "3:2", "2:3", "auto"

input.resolution
必填
string

必填。输出图像分辨率。

可选值:"1K", "2K"

input.nsfw_checker
可选
boolean

默认 false。为 false 时不额外进行内容过滤,结果由模型直接返回。

请求示例
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "flux-2/pro-image-to-image",
  "input": {
    "input_urls": [
      "https://example.com/input.png",
      "https://example.com/input.png"
    ],
    "prompt": "The jar in image 1 is filled with capsules exactly same as image 2 with the exact logo",
    "aspect_ratio": "1:1",
    "resolution": "1K"
  }
}'
返回值与错误

HTTP 200

请求成功

参数类型说明与限制
code
可选
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

可选值:200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

msg
可选
string

Response message, error description upon failure

data
必填
object
data.taskId
必填
string

The task ID can be used with the "Get Task Details" endpoint to query the task status.

Flux-2 Pro 文生图

POST/api/v1/jobs/createTask

模型标识: flux-2/pro-text-to-image

参数类型说明与限制
model
必填
string

用于生成的模型名称。必填字段。 - 此端点必须使用 `flux-2/pro-text-to-image`

可选值:"flux-2/pro-text-to-image"

默认:"flux-2/pro-text-to-image"

callBackUrl
可选
string

接收生成任务完成更新的 URL。可选但建议在生产环境中使用。 - 当生成完成时,系统将向此 URL POST 任务状态和结果 - 回调包含生成的内容 URL 和任务信息 - 您的回调端点应接受包含结果的 JSON 负载的 POST 请求 - 或者,使用获取任务详情端点轮询任务状态 - 为确保回调安全性,请参阅 [Webhook 校验指南](/cn/common-api/webhook-verification) 了解签名验证实现方法

input
可选
object

生成任务的输入参数

input.prompt
必填
string

长度必须在 3-5000 字符之间。(最大长度:5000 字符)

maxLength: 5000

input.aspect_ratio
必填
string

必填。生成图像的宽高比。

可选值:"1:1", "4:3", "3:4", "16:9", "9:16", "3:2", "2:3"

input.resolution
必填
string

必填。输出图像分辨率。

可选值:"1K", "2K"

input.nsfw_checker
可选
boolean

默认 false。为 false 时不额外进行内容过滤,结果由模型直接返回。

请求示例
curl -X POST 'https://api.vezapi.com/api/v1/jobs/createTask' \
  -H 'Authorization: Bearer YOUR_VEZAPI_KEY' \
  -H 'Idempotency-Key: your-unique-request-id' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "flux-2/pro-text-to-image",
  "input": {
    "prompt": "Hyperrealistic supermarket blister pack on clean olive green surface. No shadows. Inside: bright pink 3D letters spelling \"FLUX.2\" pressing against stretched plastic film, creating realistic deformation and reflective highlights. Bottom left corner: barcode sticker with text \"GENERATE NOW\" and \"PLAYGROUND\". Plastic shows tension wrinkles and realistic shine where stretched by the volumetric letters.",
    "aspect_ratio": "1:1",
    "resolution": "1K"
  }
}'
返回值与错误

HTTP 200

请求成功

参数类型说明与限制
code
可选
integer

Status code of the request. The HTTP status is 200 even when the request fails, so always check this field: 200 means success; any other value means the request failed and msg describes the reason. Common values: 401 invalid or missing API key; 402 insufficient credits; 429 rate limit exceeded; 422 or 500 the request could not be processed (read msg and check your parameters before retrying).

可选值:200, 401, 402, 404, 422, 429, 433, 455, 500, 501, 505

msg
可选
string

Response message, error description upon failure

data
必填
object
data.taskId
必填
string

The task ID can be used with the "Get Task Details" endpoint to query the task status.

任务状态与回调

异步任务请保存返回的 taskId。调用 GET /api/v1/jobs/recordInfo?taskId=... 查询,或在创建时设置 callBackUrl。只有任务所属账号可以查询任务或基于任务创建派生资源。

超时可能表示请求已经受理。请在控制台查看原请求,不要自动新建任务。回调可能重试并重复到达,请使用 X-VezAPI-Event-Id 去重。

文件、日志与计费

生成媒体通常随上游保留 14 天,上传文件在 24 小时后失效。请在过期前保存所需文件。VezAPI 仅流式转发已登记资源,不提供永久作品库。请求日志保留两个自然月。

调用前预留积分,最终按实际优惠扣分 1:1 结算。用量不明时暂停新付费请求。若保护其他任务预留后余额不足以结算,会保留待结算记录,补足余额后再扣费;模型用量不会将钱包扣成负数。按时长计价的输入文件由服务端读取时长,读取失败时不提交模型任务。

打开完整文档 →

FLUX.2 API 价格

下方费率为参考估算,最终按实际优惠扣分 1:1 结算。按标准充值包换算,1,000 积分约为 10 美元,大额充值包可降低每积分实际单价。

规格积分计价单位美元参考
Black Forest Labs Flux 2 Flex, text to image, 1.0s-1K14每张图片$0.14
Black Forest Labs Flux 2 Flex, text to image, 1.0s-2K24每张图片$0.24
Black Forest Labs Flux 2 Flex, image to image, 1.0s-2K24.0每张图片$0.24
Black Forest Labs flux-2 pro, text-to-image, 1.0s-2K7.0每张图片$0.07
Black Forest Labs Flux 2 Flex, image to image, 1.0s-1K14.0每张图片$0.14
Black Forest Labs flux-2 pro, image to image, 1.0s-2K7.0每张图片$0.07
Black Forest Labs flux-2 pro, text-to-image, 1.0s-1K5.0每张图片$0.05
Black Forest Labs flux-2 pro, image to image, 1.0s-1K5.0每张图片$0.05