- 异步处理模式,提交后返回任务 ID
-
支持文生图、图生图和多参考图融合
-
支持 Flex、Pro、Max 三种模型,最高输出 4MP 图像
请求示例
bash
curl --request POST \
--url https://api.openveer.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flux-2-pro",
"prompt": "一只蓝色的猫在草地上",
"resolution": "2MP",
"size": "16:9",
"output_format": "jpeg"
}'
```python
import requests
url = "https://api.openveer.com/v1/images/generations"
payload = {
"model": "flux-2-pro",
"prompt": "一只蓝色的猫在草地上",
"resolution": "2MP",
"size": "16:9",
"output_format": "jpeg"
}
headers = {
"Authorization": "Bearer
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
```
```javascript
const url = "https://api.openveer.com/v1/images/generations";
const payload = {
model: "flux-2-pro",
prompt: "一只蓝色的猫在草地上",
resolution: "2MP",
size: "16:9",
output_format: "jpeg"
};
const headers = {
"Authorization": "Bearer
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
```
响应示例
json
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01KFG5BBFNK1YQDTJDZY0P0QT2"
}
]
}
json
{
"error": {
"code": 401,
"message": "身份验证失败,请检查您的 API 密钥",
"type": "authentication_error"
}
}
json
{
"error": {
"code": 402,
"message": "账户余额不足,请充值后再试",
"type": "payment_required"
}
}
支持的模型
| 模型名 | 说明 |
|---|---|
flux-2-flex |
支持精细控制,可调整采样步数和提示词引导强度 |
flux-2-pro |
兼顾速度与质量,适合通用生产工作流 |
flux-2-max |
最高质量版本,适合对图像质量要求较高的场景 |
除标注为 Flex 专有的参数外,下列参数和像素限制均适用于以上三种模型。
Authorizations
Authorization stringBody
model stringprompt stringresolution stringsize stringwidth integerheight integerimage_urls arrayoutput_format stringn integerseed integerprompt_upsampling booleansafety_tolerance integersteps integerguidance number分辨率对照表
| 比例 | 1MP |
2MP(默认) |
3MP |
4MP |
|---|---|---|---|---|
1:1 |
1024×1024 | 1440×1440 | 1536×1536 | 2048×2048 |
4:3 |
1152×864 | 1664×1248 | 1824×1360 | 2336×1760 |
3:4 |
864×1152 | 1248×1664 | 1360×1824 | 1760×2336 |
16:9 |
1344×752 | 1920×1072 | 2048×1152 | 2720×1536 |
9:16 |
752×1344 | 1072×1920 | 1152×2048 | 1536×2720 |
3:2 |
1248×832 | 1728×1152 | 1872×1248 | 2496×1664 |
2:3 |
832×1248 | 1152×1728 | 1248×1872 | 1664×2496 |
21:9 |
1504×640 | 2176×928 | 2304×992 | 3072×1312 |
9:21 |
640×1504 | 928×2176 | 992×2304 | 1312×3072 |
尺寸参数优先级为:成对的 width + height → size 像素串 → resolution + size 宽高比 → 默认 2MP + 1:1。
使用场景示例
基础文生图
{
"model": "flux-2-pro",
"prompt": "赛博朋克风格的城市夜景,霓虹灯反射在湿润街道上",
"resolution": "1MP",
"size": "16:9"
}
最高质量生成
{
"model": "flux-2-max",
"prompt": "清晨薄雾中的雪山与湖泊,细节丰富,电影感",
"resolution": "4MP",
"size": "3:2"
}
精确像素尺寸
{
"model": "flux-2-pro",
"prompt": "一只蓝色的猫",
"width": 1024,
"height": 1536
}
多参考图融合
{
"model": "flux-2-pro",
"prompt": "把图 1 的人物放进图 2 的场景,统一光照和色调",
"image_urls": [
"https://example.com/person.jpg",
"https://example.com/scene.jpg"
],
"resolution": "2MP",
"size": "16:9"
}
Flex 精细控制
{
"model": "flux-2-flex",
"prompt": "极简风格海报,大标题写 SUMMER SALE,下方小字写 50% OFF",
"resolution": "3MP",
"size": "3:4",
"steps": 50,
"guidance": 6.5
}
Response
提交成功后,data 为数组,任务 ID 位于 data[0].task_id。
code integerdata arraytask_id string查询任务结果
任务为异步处理。使用提交响应中的 task_id 请求以下接口,直到状态变为 completed 或 failed:
curl --request GET \
--url https://api.openveer.com/v1/tasks/task_01KFG5BBFNK1YQDTJDZY0P0QT2 \
--header 'Authorization: Bearer <token>'
任务状态包括:
| 状态 | 说明 |
|---|---|
submitted / pending |
任务已受理或正在排队,请继续轮询 |
processing |
图像正在生成,请继续轮询 |
completed |
任务完成,可从 result.images[0].url[0] 获取图片 URL |
failed |
任务失败,可查看 data.error.message;任务费用会全额退还 |
完成响应示例:
{
"code": 200,
"data": {
"id": "task_01KFG5BBFNK1YQDTJDZY0P0QT2",
"status": "completed",
"progress": 100,
"result": {
"images": [
{
"url": [
"https://upload.apimart.ai/f/image/xxxxxxxx-flux-2.jpeg"
],
"expires_at": 1785220083
}
]
}
}
}
result.images[].url 是字符串数组。本系列每次固定生成 1 张图片,请读取 url[0]。图片 URL 的有效期以同一对象中的 expires_at Unix 时间戳为准,请在到期前保存生成结果。
参数错误与失败响应
模型参数无效时,提交接口仍会返回 HTTP 200 和 task_id。请持续轮询,任务随后会进入 failed 状态,并在 data.error.message 中返回具体原因。失败任务会全额退款。
{
"code": 200,
"data": {
"status": "failed",
"error": {
"type": "task_failed",
"code": "task_failed",
"message": "`steps` must be between 1 and 50 (got 0)"
}
}
}
error.code 固定为 task_failed,具体失败原因请读取 error.message。
注意事项
- 尺寸限制:输出图像不得超过 4MP,且宽、高均不得小于 64 像素。
- 总像素限制:输出图像与所有参考图的总像素不得超过 9MP。
- 参考图要求:最多支持 8 张参考图,可使用公网可访问的图片 URL 或 Base64 输入。
- 固定生成张数:
n默认且只能为1。 - 提示词增强:
prompt_upsampling默认为false;显式传入false可关闭提示词改写。 - Flex 专有参数:
steps和guidance仅适用于flux-2-flex。 - 异步任务:提交成功后,请轮询
/v1/tasks/{task_id}获取最终结果。 - 结果链接:图片 URL 的有效期以响应中的
expires_at为准。 - 异步参数错误:非法模型参数不会在提交时同步返回 4xx;必须轮询到
failed并读取data.error.message。