🎨 ChatGPT 最新生图 gpt-image-2-all 已上线 | Now Live:$0.03/张图,对话式端点提示词遵循最佳!详情 Details
curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "flux-2-pro",
"prompt": "A cinematic shot of a futuristic city at sunset, 85mm lens"
}
'{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}FLUX 文生图 API 参考与在线调试 — FLUX.2 [klein/pro/max/flex] 全系列 OpenAI 兼容直连,支持 4MP 输出与 hex 精确色控
curl --request POST \
--url https://api.apiyi.com/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "flux-2-pro",
"prompt": "A cinematic shot of a futuristic city at sunset, 85mm lens"
}
'{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}Documentation Index
Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
Use this file to discover all available pages before exploring further.
Bearer sk-xxx),输入 prompt、选择模型与尺寸后一键发送即可。data[0].url 必须立即下载,过期返回 404width / height 必须是 16 的倍数 — 不满足会 400 报错prompt_upsampling FLUX.2 [klein] 不支持 — 传入会被忽略grounding search 仅 flux-2-max — 其它模型 prompt 含实时知识也不会触发from openai import OpenAI
import requests
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.apiyi.com/v1"
)
resp = client.images.generate(
model="flux-2-pro",
prompt="A cinematic shot of a futuristic city at sunset, 85mm lens, hyper-realistic",
size="1920x1080"
)
# data[0].url 仅 10 分钟有效,立即下载
image_url = resp.data[0].url
with open("out.jpg", "wb") as f:
f.write(requests.get(image_url, timeout=30).content)
import requests
API_KEY = "sk-your-api-key"
response = requests.post(
"https://api.apiyi.com/v1/images/generations",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"model": "flux-2-max",
"prompt": "Score of yesterday's Champions League final, infographic style",
"width": 1920,
"height": 1080,
"safety_tolerance": 2,
"output_format": "jpeg",
"seed": 42
},
timeout=120
).json()
image_url = response["data"][0]["url"]
with open("out.jpg", "wb") as f:
f.write(requests.get(image_url, timeout=30).content)
curl -X POST "https://api.apiyi.com/v1/images/generations" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2-pro",
"prompt": "Luxury eyeshadow palette with 6 pans: top row #B76E79, #E8D5B7, #8B4789; bottom row #CD7F32, #F8F6F0, #800020",
"size": "1024x1024",
"output_format": "png"
}'
import fs from 'node:fs';
const resp = await fetch('https://api.apiyi.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-your-api-key'
},
body: JSON.stringify({
model: 'flux-2-klein-9b',
prompt: 'A serene mountain landscape at golden hour, soft diffused light',
width: 1024,
height: 1024
})
});
const { data } = await resp.json();
// 立即下载 - URL 10 分钟过期
const img = await fetch(data[0].url);
fs.writeFileSync('out.jpg', Buffer.from(await img.arrayBuffer()));
{/* 仅作演示,生产请走后端代理避免 Key 泄露;URL 不开 CORS,需要后端代下载 */}
const resp = await fetch('https://api.apiyi.com/v1/images/generations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-your-api-key'
},
body: JSON.stringify({
model: 'flux-2-pro',
prompt: 'Watercolor aurora borealis over Nordic mountains',
size: '1536x1024'
})
});
const { data } = await resp.json();
{/* delivery URL 不开 CORS,浏览器直接 <img src> 渲染可行(不走 fetch 即可),但建议后端代下载到自有 CDN */}
document.getElementById('img').src = data[0].url;
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
model | string | 是 | — | FLUX 模型 ID,见下表 |
prompt | string | 是 | — | 提示词,最长 32K tokens,支持中英文与结构化 JSON |
size | string | 否 | 1024x1024 | OpenAI 风格尺寸字符串,如 1920x1080 |
width | integer | 否 | 1024 | BFL 原生写法,与 size 二选一,必须 16 倍数 |
height | integer | 否 | 1024 | BFL 原生写法,必须 16 倍数 |
seed | integer | 否 | 随机 | 固定可复现 |
safety_tolerance | integer | 否 | 2 | 0(最严)– 6(最宽松) |
output_format | string | 否 | jpeg | jpeg / png |
prompt_upsampling | boolean | 否 | false | 自动扩写 prompt([klein] 不支持) |
steps | integer | 否 | 50 | 仅 flux-2-flex,最大 50 |
guidance | number | 否 | 4.5 | 仅 flux-2-flex,1.5–10 |
n | integer | 否 | 1 | 仅支持 1 |
| 模型 ID | 速度 | 适用 |
|---|---|---|
flux-2-max | < 15s | 旗舰画质 + 联网搜索 |
flux-2-pro | < 10s | 生产规模、最佳性价比 |
flux-2-flex | 较慢 | 文字渲染特化 |
flux-2-klein-9b | sub-second | 平衡型 |
flux-2-klein-4b | sub-second | 最快 |
flux-pro-1.1-ultra | ~10s | 老版 4MP(详见历史版本页) |
flux-pro-1.1 | ~5s | 老版 1.6MP |
flux-pro | ~6s | 初代 pro |
flux-dev | ~5s | 开发版 |
{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}
data[0].url 仅 10 分钟有效delivery-eu.bfl.ai / delivery-us.bfl.ai,签名 10 分钟过期fetch 会被拦,但 <img src> 直显可行gpt-image-2(返回 b64_json 纯 base64)不同,FLUX 走 URL,不返回 base64。usage 字段(按张计费而非按 token),实际扣费按本文档定价表执行。响应头 x-request-id 用于排查。在 API易控制台获取的 API Key
FLUX 模型 ID。FLUX.2 推荐 flux-2-pro / flux-2-max;旧版见历史版本页
flux-2-max, flux-2-pro, flux-2-flex, flux-2-klein-9b, flux-2-klein-4b, flux-pro-1.1-ultra, flux-pro-1.1, flux-pro, flux-dev 提示词,最长 32K tokens。支持自然语言、hex 色码、结构化 JSON
"A cinematic shot of a futuristic city at sunset, 85mm lens"
OpenAI 风格尺寸字符串,与 width/height 二选一。
常用:1024x1024 / 1536x1024 / 1024x1536 / 1920x1080 / 1440x2048 / 2048x2048。
自定义需满足:边长 16 倍数、64×64–4MP 之间。
"1920x1080"
BFL 原生写法,与 size 二选一。必须是 16 的倍数,64–2048 之间
64 <= x <= 20481920
BFL 原生写法,必须是 16 的倍数,64–2048 之间
64 <= x <= 20481080
固定可复现,传相同 seed + 相同其它参数得一致结果
42
审核档位。0 最严格,6 最宽松,默认 2
0 <= x <= 6输出格式
jpeg, png 是否自动扩写 prompt。FLUX.2 [klein] 不支持,传入会被忽略
仅 flux-2-flex。推理步数,最大 50
1 <= x <= 50仅 flux-2-flex。引导强度。1.5–10,越高越贴 prompt
1.5 <= x <= 10出图数量。本接口仅支持 1
1 此页面对您有帮助吗?