FLUX.2 [klein] 4B Image-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/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
- 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
Keep the product while changing the background, lighting, or visual style with natural-language instructions.
image_urlspromptThe 4B route is tiered by output resolution: draft at 0.25 MP or 0.5 MP, then finish at 2 MP or 4 MP.
resolutionUse match_input_image to keep the reference ratio, or switch to a common landscape or portrait format.
aspect_ratioSet a seed to compare parameter changes with the same input and instruction.
seedRequest parameters
model string required Fixed value 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.
aspect_ratio enum optional Output aspect ratio. Use match_input_image to preserve the reference image ratio.
seed integer optional Random seed for reproducible generation.
output_format enum optional Format of the generated image.
output_quality integer optional Compression quality for jpg and webp output.
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.
when enum optional Callback trigger timing. Use final.
Example requests
Uses one public reference image, preserves the subject and angle, and replaces the background with controlled rim lighting.
{
"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
- The response returns a taskId immediately without waiting for generation to finish.
- In production, prefer waiting for callback.url to receive 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
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.