APIMODELSAPIMODELS
Документация API

apimodels.app

Docs/FLUX.2 Klein 4B API

FLUX.2 Klein 4B API

FLUX.2 Klein 4B image generation — fast (1-2s), crisp, photoreal. Text-to-image, or image-to-image with up to 3 reference images (each auto-compressed to ~1MP). Output is fixed at ~2MP, with 12 aspect ratios (including match_input_image) and jpg/png/webp output.

Authentication

Authorization: Bearer YOUR_API_KEY

Model & pricing

ModelmodelPriceNotes
FLUX.2 Klein 4Bflux-2-klein-4bfrom $0.006Output 2MP $0.006 + $0.0015 per reference image (max 3)

Pricing examples: text-to-image $0.006; with 1 reference $0.0075; with 3 references $0.0105. Failed requests are not charged.

Code examples

# ─── 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/..."] } }

Request parameters

FieldRequiredTypeDescription
modelYesstringflux-2-klein-4b
promptYesstringText description of the image
image_urlsNostring[]Array of reference-image URLs, up to 3 (image-to-image). Each is auto-compressed to ~1MP.
aspect_ratioNostring1:1 16:9 9:16 3:2 2:3 4:3 3:4 5:4 4:5 21:9 9:21 match_input_image (default 1:1)
output_formatNostringjpg / png / webp (default jpg)
seedNonumberRandom seed for reproducible output
callback_urlNostringWebhook URL called when the task completes

Notes

  • Text-to-image omits image_urls; image-to-image passes 1-3 image_urls
  • Output is fixed at ~2MP; there are no resolution tiers to price
  • To match the reference ratio, use aspect_ratio: "match_input_image"
  • Async: create a task for a taskId, then poll GET ?task_id= for the result
  • Charged only on success

Try it in the Playground

FAQ

How much does FLUX.2 Klein 4B cost?

From $0.006 per image: a 2MP output is $0.006, and each reference image adds $0.0015 (up to 3), so image-to-image with 1 reference is $0.0075 and with 3 is $0.0105. Charged only on success.

How many reference images does FLUX.2 Klein 4B support?

Up to 3 reference images for image-to-image via image_urls; each is auto-compressed to ~1MP. Use aspect_ratio "match_input_image" to follow the reference ratio.