
The FLUX.2 [klein] model family are our fastest image models to date. FLUX.2 [klein] unifies generation and editing in a single compact architecture, delivering state-of-the-art quality with end-to-end inference in as low as under a second.
Template










The Klein API provides a synchronous interface for generating high-quality images from text prompts and reference images. All generation workflows are accessed through a single endpoint. The API automatically selects the appropriate workflow based on the number of reference images provided:
All requests to the API must include a Bearer token in the Authorization header.
Example header:
Authorization: Bearer YOUR_API_KEY
Generates or edits an image based on a text prompt and optional reference images. Uses multipart/form-data content type.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| prompt | string | Yes | - | The text description of the image to generate. |
| model | string | No | flux2-klein-4b | Model identifier. Use flux2-klein-4b. |
| aspect_ratio | string | No | landscape | The desired aspect ratio for the output image. Valid values: square, landscape, portrait, photo, photo_v, standard, standard_v, wide. |
| images | file[] | No | [] | Uploaded image files to use as references. Takes priority over image_uris. |
| image_uris | string | No | - | A JSON array of URLs or base64 data URIs of the reference images. |
The workflow is automatically determined by the total number of reference images (from images and image_uris combined):
| Reference Images | Workflow | Description |
|---|---|---|
| 0 | Text-to-image | Generates an image purely from the text prompt. |
| 1 | Image-to-image | Edits a single reference image based on the text prompt. |
| 2–4 | Multi-reference | Generates an image using multiple references and the text prompt. |
Text-to-image (no images):
curl -X POST https://us-01.bytecompute.ai/v1/generate \
-H "Authorization: Bearer " \
-F "prompt=A futuristic city with neon lights" \
-F "model=flux2-klein-4b" \
-F "aspect_ratio=square"
Image-to-image (1 image):
curl -X POST https://us-01.bytecompute.ai/v1/generate \
-H "Authorization: Bearer " \
-F "prompt=A cat wearing a space suit" \
-F "model=flux2-klein-4b" \
-F "images=@/path/to/your/image.png" \
-F "aspect_ratio=portrait"
Multi-reference (2+ images):
curl -X POST https://us-01.bytecompute.ai/v1/generate \
-H "Authorization: Bearer " \
-F "prompt=A hybrid of these two animals" \
-F "model=flux2-klein-4b" \
-F "images=@/path/to/image1.png" \
-F "images=@/path/to/image2.png" \
-F "aspect_ratio=landscape"
The response body contains the raw PNG bytes of the generated image with a Content-Type of image/png.
Response headers:
X-Generation-Id: Unique identifier for the generation.X-Generation-Time: Time taken to generate the image in seconds.X-Resolution: Resolution of the generated image.X-Model: Model identifier used.X-Workflow: Workflow that was selected (t2i, i2i, or multi-ref).X-Reference-Count: The number of reference images used (only present when images are provided).The API uses standard HTTP status codes to indicate the success or failure of a request. Errors are returned in a unified JSON format.
{
"detail": "Error message description"
}
Status codes:
| Limit | Value |
|---|---|
| Maximum Reference Images | 4 |
Available aspect ratios and their corresponding resolutions:
| Aspect Ratio | Resolution |
|---|---|
| square | 1024 x 1024 |
| landscape | 1344 x 768 |
| portrait | 768 x 1344 |
| photo | 1248 x 832 |
| photo_v | 832 x 1248 |
| standard | 1184 x 896 |
| standard_v | 896 x 1184 |
| wide | 1568 x 672 |
Run models at scale with our fully managed GPU infrastructure, delivering enterprise-grade uptime at the industry's best rates.