FLUX.2 [klein] 4B Text-to-Image API
/v1/tasks All models are called through the Unified Async API POST /v1/tasks endpoint; only the input fields differ (see input parameters below).
Model summary
| Model name | flux-2-klein-4b/text-to-image |
|---|---|
| Type | Image generation (text-to-image) |
| Endpoint | POST /v1/tasks |
| Pricing | See HiAPI Pricing |
A compact, fast, and cost-efficient FLUX.2 text-to-image model with tiered 0.25-4 MP output for volume production and flexible publishing formats.
Production guidance
- Pass callback.url at the top level so HiAPI can notify your service when the task reaches a terminal state.
- Use GET /v1/tasks/:id for local debugging or fallback reconciliation.
- Price changes with the resolution tier; estimate cost using the actual output tier before submitting.
Best suited for
Lower megapixel tiers suit high-volume concepts, product-shot drafts, and ad variants with tight cost control.
promptresolutionaspect_ratioLandscape, portrait, square, and ultra-wide ratios cover common publishing formats.
promptaspect_ratioChoose 2 MP or 4 MP for a larger canvas, product detail, or downstream layout work.
resolutionoutput_formatoutput_qualityFix the seed to preserve the overall direction while refining the prompt.
promptseedRequest parameters
model string required Fixed value flux-2-klein-4b/text-to-image.
input object required Business parameters for FLUX.2 [klein] 4B.
prompt string required Text prompt for image generation.
resolution enum optional Output megapixel tier. Pricing is tiered across 0.25, 0.5, 1, 2, and 4 MP.
aspect_ratio enum optional Aspect ratio for the generated image, including landscape, portrait, square, and ultra-wide formats.
seed integer optional Random seed for reproducible generation.
output_format enum optional File format of the generated image.
output_quality integer optional Compression quality from 0 to 100 for jpg and webp. It does not affect png.
callback object optional Optional callback configuration for terminal task notifications.
url string required Required when callback is set; HTTPS URL that receives terminal task notifications.
when enum optional Callback trigger timing. Use final.
Example requests
A 1 MP square render for evaluating material, rim light, and glass refraction.
{
"model": "flux-2-klein-4b/text-to-image",
"input": {
"prompt": "A translucent amber perfume bottle on dark volcanic stone, dramatic studio rim lighting, premium commercial photography, realistic glass refraction",
"resolution": "1 MP",
"aspect_ratio": "1:1",
"output_format": "jpg",
"output_quality": 95
}
}A 16:9, 2 MP render suited to landscape ads and website hero artwork.
{
"model": "flux-2-klein-4b/text-to-image",
"input": {
"prompt": "A futuristic electric motorcycle displayed in a brutalist concrete gallery, wet reflective floor, dramatic cyan and amber rim lighting",
"resolution": "2 MP",
"aspect_ratio": "16:9",
"seed": 84,
"output_format": "png"
}
}Getting the result
- The response returns a taskId immediately without waiting for generation to finish.
- In production, prefer callback.url for the terminal notification. For local debugging, poll GET /v1/tasks/:id.
- When status=success, download the generated image from output[].url.
- When status=fail, fix the request based on the returned error instead of retrying the same invalid payload.
FAQ
What is the FLUX.2 [klein] 4B API?
It is a compact FLUX.2 text-to-image model designed for fast, low-cost generation. HiAPI currently exposes it for batch drafts, product concepts, and multi-format content.
How is FLUX.2 [klein] 4B priced on HiAPI?
Pricing is tiered by output resolution from 0.25 MP to 4 MP. Use the live pricing page for current rates. View live pricing
Which resolutions and aspect ratios does FLUX.2 [klein] 4B support?
It supports five resolution tiers from 0.25 MP to 4 MP, plus square, landscape, portrait, and ultra-wide formats. See the request parameters above for every accepted value.
Should I choose FLUX.2 [klein] 4B or 9B?
4B prioritizes generation speed and cost control, while 9B balances speed with image quality. In HiAPI dev tests, 9B was more reliable for complex scenes and English in-image text, although important text still needs review. Read the 9B API docs
Does FLUX.2 [klein] 4B support image editing?
This page exposes text-to-image generation only and does not accept a reference image or image-editing parameters. Use a dedicated image-to-image model to modify an existing image.