FLUX.2 Klein 4B 图片生成——快(1-2 秒出图)、锐利、照片级。文生图,或最多带 3 张参考图做图生图(每张自动压缩到约 1MP)。输出固定约 2MP,支持 12 种画幅(含 match_input_image 跟随参考图比例)与 jpg/png/webp 输出。
Authorization: Bearer YOUR_API_KEY| 模型 | model | 价格 | 说明 |
|---|---|---|---|
| FLUX.2 Klein 4B | flux-2-klein-4b | $0.006 起 | 输出 2MP $0.006 + 每张参考图 $0.0015(最多 3 张) |
计费示例:纯文生图 $0.006;带 1 张参考图 $0.0075;带 3 张 $0.0105。失败不扣费。
# ─── Text-to-image ────────────────────────────────────────
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2-klein-4b",
"prompt": "a serene mountain lake at sunrise, photorealistic",
"aspect_ratio": "3:2",
"output_format": "jpg"
}'
# Response (async — a task is created):
# { "code": 200, "data": { "taskId": "clxxx", "state": "pending" } }
# ─── Image-to-image (up to 3 reference images) ────────────
curl -X POST https://api.apimodels.app/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2-klein-4b",
"prompt": "restyle as a soft watercolor painting",
"image_urls": ["https://example.com/a.jpg", "https://example.com/b.jpg"],
"aspect_ratio": "match_input_image"
}'
# ─── Poll for the result ──────────────────────────────────
curl "https://api.apimodels.app/v1/images/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
# { "code": 200, "data": { "state": "completed", "resultUrls": ["https://r2.apimodels.app/..."] } }| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | flux-2-klein-4b |
| prompt | 是 | string | 图片文字描述 |
| image_urls | 否 | string[] | 参考图 URL 数组,最多 3 张(图生图)。每张自动压缩到约 1MP。 |
| aspect_ratio | 否 | string | 1:1 16:9 9:16 3:2 2:3 4:3 3:4 5:4 4:5 21:9 9:21 match_input_image(默认 1:1) |
| output_format | 否 | string | jpg / png / webp(默认 jpg) |
| seed | 否 | number | 随机种子,固定可复现 |
| callback_url | 否 | string | 任务完成后的回调 URL |
试一试:Playground
$0.006/张起:2MP 输出 $0.006,每张参考图 +$0.0015(最多 3 张),所以带 1 张参考图 $0.0075、带 3 张 $0.0105。仅成功扣费。
图生图最多 3 张参考图(image_urls),每张自动压缩到约 1MP。用 aspect_ratio "match_input_image" 跟随参考图比例。