🎨 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 text-to-image API reference and live debugger — full FLUX.2 [klein/pro/max/flex] family via OpenAI-compatible drop-in, 4MP output and exact hex color control
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), choose model and size, enter the prompt, and send.data[0].url must be downloaded immediately, expired URLs return 404width / height must be multiples of 16 — otherwise returns 400prompt_upsampling is not supported on FLUX.2 [klein] — silently ignoredgrounding search only on flux-2-max — other models will not trigger live search even with time-sensitive promptsfrom 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 is valid for only 10 minutes — download immediately
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();
// Download immediately — URL expires in 10 minutes
const img = await fetch(data[0].url);
fs.writeFileSync('out.jpg', Buffer.from(await img.arrayBuffer()));
{/* Demo only — production should proxy via backend to avoid leaking the key. The delivery URL has CORS disabled, so server-side download to your own CDN is recommended. */}
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 has CORS disabled, but <img src> works for direct rendering. Server-side download is still recommended for production. */}
document.getElementById('img').src = data[0].url;
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | FLUX model ID, see table below |
prompt | string | Yes | — | Prompt, up to 32K tokens. Supports natural language and structured JSON |
size | string | No | 1024x1024 | OpenAI-style size string, e.g., 1920x1080 |
width | integer | No | 1024 | BFL-native, alternative to size, must be multiple of 16 |
height | integer | No | 1024 | BFL-native, must be multiple of 16 |
seed | integer | No | random | Fix for reproducibility |
safety_tolerance | integer | No | 2 | 0 (strictest) – 6 (most permissive) |
output_format | string | No | jpeg | jpeg / png |
prompt_upsampling | boolean | No | false | Auto-expand prompt (not on [klein]) |
steps | integer | No | 50 | Only for flux-2-flex, max 50 |
guidance | number | No | 4.5 | Only for flux-2-flex, 1.5–10 |
n | integer | No | 1 | Only 1 supported |
| Model ID | Speed | Best For |
|---|---|---|
flux-2-max | < 15s | Flagship + grounding search |
flux-2-pro | < 10s | Production at scale, best value |
flux-2-flex | Slower | Typography specialist |
flux-2-klein-9b | Sub-second | Balanced |
flux-2-klein-4b | Sub-second | Fastest |
flux-pro-1.1-ultra | ~10s | Legacy 4MP (see Historical Versions) |
flux-pro-1.1 | ~5s | Legacy 1.6MP |
flux-pro | ~6s | First-gen pro |
flux-dev | ~5s | Dev/test |
{
"created": 1776832476,
"data": [
{
"url": "https://delivery-eu.bfl.ai/results/xxx/sample.jpeg?signature=..."
}
]
}
data[0].url is valid for only 10 minutesdelivery-eu.bfl.ai / delivery-us.bfl.ai, signature expires after 10 minfetch is blocked, but <img src> rendering worksgpt-image-2 (which returns b64_json), FLUX returns URL only — no base64.usage field (priced per image, not per token). Actual billing follows the pricing table on this site. The response header x-request-id is for support tracing.API Key from the APIYI Console
FLUX model ID. For FLUX.2 prefer flux-2-pro / flux-2-max; legacy versions in the Historical Versions page.
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 Prompt, up to 32K tokens. Supports natural language, hex codes, and structured JSON.
"A cinematic shot of a futuristic city at sunset, 85mm lens"
OpenAI-style size string. Pick either size or width+height.
Common: 1024x1024 / 1536x1024 / 1024x1536 / 1920x1080 / 1440x2048 / 2048x2048.
Custom must satisfy: multiples of 16, 64×64–4MP.
"1920x1080"
BFL-native syntax, alternative to size. Must be a multiple of 16, between 64 and 2048.
64 <= x <= 20481920
BFL-native syntax. Must be a multiple of 16, between 64 and 2048.
64 <= x <= 20481080
Fix for reproducibility — same seed + same other params yields the same result.
42
Moderation level. 0 = strictest, 6 = most permissive, default 2.
0 <= x <= 6Output format.
jpeg, png Auto-expand the prompt. Not supported on FLUX.2 [klein] (silently ignored).
Only flux-2-flex. Inference steps, max 50.
1 <= x <= 50Only flux-2-flex. Guidance scale. 1.5–10, higher = closer to prompt.
1.5 <= x <= 10Number of images. Only 1 supported.
1