Skip to content
English

FLUX.2 [klein] 4B Image-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/image-to-image
Type Image generation (image-to-image)
Endpoint POST /v1/tasks
Pricing See HiAPI Pricing

FLUX.2 [klein] 4B image-to-image API for single-reference instruction editing up to 4 MP, with resolution-tier pricing for fast, low-cost iteration.

Production guidance

Production guidance
  • For production, pass callback.url at the top level of the request body so HiAPI can notify your service when the task reaches a terminal state.
  • GET /v1/tasks/:id is better for local debugging, low-volume jobs, or fallback reconciliation if a callback is missed.
  • Use callback.when=final. Both success and fail are terminal states, so your service should deduplicate by taskId.

Best suited for

Product-image variants

Keep the product while changing the background, lighting, or visual style with natural-language instructions.

image_urlsprompt
Low-cost iteration

The 4B route is tiered by output resolution: draft at 0.25 MP or 0.5 MP, then finish at 2 MP or 4 MP.

resolution
Preserve composition

Use match_input_image to keep the reference ratio, or switch to a common landscape or portrait format.

aspect_ratio
Reproducible edits

Set a seed to compare parameter changes with the same input and instruction.

seed

Request parameters

model string required

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

example flux-2-klein-4b/image-to-image
input object required

Business parameters. Put FLUX.2 [klein] 4B Image to Image-specific configuration here.

prompt string required

Describe the edits to apply to the reference image.

image_urls string[] required

One reference image. Supports jpeg, png, or webp; svg is not supported. Images above 4 MP are resized to 4 MP.

resolution enum optional

Output size in megapixels.

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

Output aspect ratio. Use match_input_image to preserve the reference image ratio.

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

Random seed for reproducible generation.

output_format enum optional

Format of the generated image.

default jpg enum: webpjpgpng
output_quality integer optional

Compression quality for jpg and webp output.

default 95
callback object optional

Optional callback configuration. When set, HiAPI notifies your service when the task reaches a terminal state.

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

Studio background replacement (2 MP)

Uses one public reference image, preserves the subject and angle, and replaces the background with controlled rim lighting.

Request body
{
  "model": "flux-2-klein-4b/image-to-image",
  "input": {
    "prompt": "Keep the subject and camera angle. Replace the background with a deep-blue studio gradient and add soft rim lighting.",
    "image_urls": [
      "https://static.hiapi.ai/gallery/2026/07/f35f947e46888163.png"
    ],
    "resolution": "2 MP",
    "aspect_ratio": "16:9",
    "seed": 20260727,
    "output_format": "png",
    "output_quality": 95
  }
}

Getting the result

  1. The response returns a taskId immediately without waiting for generation to finish.
  2. In production, prefer waiting for callback.url to receive 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

How many reference images does 4B image-to-image support?

HiAPI currently exposes one reference image so input cost and resolution-tier pricing remain predictable. image_urls must be an array containing one public image URL.

How is 4B image-to-image billed?

Pricing is tiered by output resolution: 0.25 MP, 0.5 MP, 1 MP, 2 MP, and 4 MP. See the live HiAPI pricing page for current rates. View live pricing

When should I choose 4B instead of 9B?

Choose 4B for cost-sensitive, high-volume iteration. Choose 9B when detail preservation, text rendering, and final-image quality matter more.

What are the input-image limits?

jpeg, png, and webp are supported; svg is not supported. Inputs above 4 MP are resized to 4 MP. Use a stable, publicly accessible HTTPS URL.

Next steps