Skip to content
English

FLUX.2 [klein] 4B Text-to-Image API

POST /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

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

Batch product and ad creatives

Lower megapixel tiers suit high-volume concepts, product-shot drafts, and ad variants with tight cost control.

promptresolutionaspect_ratio
Social and editorial artwork

Landscape, portrait, square, and ultra-wide ratios cover common publishing formats.

promptaspect_ratio
Higher-resolution delivery

Choose 2 MP or 4 MP for a larger canvas, product detail, or downstream layout work.

resolutionoutput_formatoutput_quality
Repeatable creative iteration

Fix the seed to preserve the overall direction while refining the prompt.

promptseed

Request parameters

model string required

Fixed value flux-2-klein-4b/text-to-image.

example 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.

default 1 MP enum: 0.25 MP0.5 MP1 MP2 MP4 MP
aspect_ratio enum optional

Aspect ratio for the generated image, including landscape, portrait, square, and ultra-wide formats.

default 1:1 enum: 1:116:99:163:22:34:33:45:44:521:99:21
seed integer optional

Random seed for reproducible generation.

output_format enum optional

File format of the generated image.

default jpg enum: webpjpgpng
output_quality integer optional

Compression quality from 0 to 100 for jpg and webp. It does not affect png.

default 95
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.

example https://your-domain.com/hiapi/callback
when enum optional

Callback trigger timing. Use final.

default final enum: final

Example requests

Premium perfume product shot

A 1 MP square render for evaluating material, rim light, and glass refraction.

Request body
{
  "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
  }
}
2 MP futuristic motorcycle ad

A 16:9, 2 MP render suited to landscape ads and website hero artwork.

Request body
{
  "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

  1. The response returns a taskId immediately without waiting for generation to finish.
  2. In production, prefer callback.url for the terminal notification. For local debugging, poll GET /v1/tasks/:id.
  3. When status=success, download the generated image from output[].url.
  4. 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.

Next steps